现象:

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'xxxService

 

错误原因:

测试类没有扫描到对应的Service类,,所以spring容器中没有Service类,使用@Autowire的时候就找不到该类,不能进行注入操作

 

解决办法

在@SpringBootTest注解的classese中写上所有要扫描和加载的类,进行扫描和注入

如下图所示

 

测试类报错 No qualifying bean of type xxxService 找不到service

相关文章:

  • 2021-12-18
  • 2021-08-04
  • 2021-04-09
  • 2021-09-09
  • 2021-11-14
  • 2022-12-23
  • 2021-04-25
  • 2022-12-23
猜你喜欢
  • 2021-06-17
  • 2022-02-06
  • 2021-04-30
  • 2021-08-08
  • 2021-09-04
  • 2021-08-06
  • 2022-12-23
相关资源
相似解决方案