解决java.lang.IllegalStateException: Failed to load ApplicationContext

 When working on a project today, I encountered the following error

java.lang.IllegalStateException: Failed to load ApplicationContext

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userServiceImpl': Injection of resource dependencies failed;

The meaning of this sentence is the reason: org.springframework.beans.factory. BeanCreationException: Error creating bean named 'userServiceImpl': Failed to inject resource dependency;

First, I checked that the @Servive annotation was added to userServiceImpl and @Resource was added 

 Then I wrote the test method in UserServiceTest and injected @SpringBootTest and

@Resource
private UserService userService;

 

However, the problem is still not resolved, and it took half an hour to figure it out.

No Mapper annotation added

Adding mapper annotations to the startup class solves the problem

 

 

Guess you like

Origin blog.csdn.net/m0_56653797/article/details/126589947