Skip to content
Advertisement

How to resolve Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type

I am getting the following error when I am trying to run my test case for a simple springboot application. Not sure what am I missing. Any help would be highly appreciated.

Controller.java

JavaScript

PersonService.java

JavaScript

PersonServiceImplementation.java

JavaScript

ControllerTest.java

Here, the BASE_REQUEST is a json string which acts as an input from the user.

JavaScript

Exception:

JavaScript

Advertisement

Answer

Please try to include the following annotations on top of the test class.

JavaScript

This will load the full context.

Apart from this Controller class also uses the PersonService class, hence that also needs to be mocked. and corresponding calls needs to be set with expected values.

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