Skip to content
Advertisement

Parameter 0 of constructor in ‘ ‘ required a bean of type ‘ ‘ that could not be found

I am creating a spring boot application, wherein any client can submit the request, these request can be GET, PUT, POST, DELETE.

But while creating this application, I am getting the following errors:

JavaScript

The structure of my application is:

enter image description here

PersonDao.java

JavaScript

PersonService.java

JavaScript

I know that many questions with the following error, are already been asked, but still I am not able to solve this.

JavaScript

I have tried to annotate PersonDao.java with @Service, @Repository, @Component, but still I am getting the same error.

I have even tried solutions from these SO answers :

(1) Parameter 0 of constructor in required a bean of type ‘java.lang.String’ that could not be found

(2) Spring – Error Parameter 0 of constructor in Service required a bean of type Configuration that could not be found

(3) Parameter 0 of constructor in ….. Spring Boot

But still I am not able to resolve my issue.

Advertisement

Answer

By adding the qualifier @Qualifier("fake demo") to public PersonService(@Qualifier("fake demo") PersonDao personDao) a bean with that qualifier is searched to be injected in PersonService which does not exist. You can declare this qualifier as well on PersonDao or remove it. I would recommend removing it. In addition you should annotate PersonDao with @Repository and extend interface org.springframework.data.repository.Repository.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement