Skip to content
Advertisement

Parameter 0 of constructor in ….. Spring Boot

I have a problem when launch my app. Could somebody help me to solve this issue?

JavaScript

GenericRepository

JavaScript

GenericRepositoryImpl

JavaScript

BookRepositorySearch

JavaScript

BookService

JavaScript

BookServiceImpl

JavaScript

Advertisement

Answer

From your previous comments, looks like you want to keep BookRepositorySearch as an interface. If that’s the case, you need to create a concrete instance of that interface and put @Component on that.

You don’t need @Component on your interface declaration and you can’t extend a class in an interface.

JavaScript

Create a concrete type that implements the interface and extends extends GenericRepository<Book, Long> you want to autowire and put @Component on it:

JavaScript

https://docs.spring.io/spring/docs/current/spring-framework-reference/core.html#beans-factory-class-ctor

Instantiation with a constructor

When you create a bean by the constructor approach, all normal classes are usable by and compatible with Spring. That is, the class being developed does not need to implement any specific interfaces or to be coded in a specific fashion. Simply specifying the bean class should suffice. However, depending on what type of IoC you use for that specific bean, you may need a default (empty) constructor.

The Spring IoC container can manage virtually any class you want it to manage; it is not limited to managing true JavaBeans. Most Spring users prefer actual JavaBeans with only a default (no-argument) constructor and appropriate setters and getters modeled after the properties in the container. You can also have more exotic non-bean-style classes in your container. If, for example, you need to use a legacy connection pool that absolutely does not adhere to the JavaBean specification, Spring can manage it as well.

Advertisement