No qualifying bean of type [xxx] found for dependency

落日映苍穹つ 2023-06-17 02:04 137阅读 0赞

描述

  • org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘xxx’:Injection of resource dependencies failed
  • org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [xxx] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency

问题来源

  • xml配置文件中没有启用注解功能或者扫描包路径错误
  • xxxServiceImpl实现类没有使用@Service注解
  • xxxService调用错误,出现自己调自己的情况

    1. <context:component-scan base-package="xxx.xxx.xxx"/>

    //此处没有使用@service
    @Service
    public class OperatorServiceImpl implements OperatorService {

    1. /* 自己调自己 @Resource private OperatorService operatorService; */
    2. @Resource
    3. private OperatorDao operatorDao;

发表评论

表情:
评论列表 (有 0 条评论,137人围观)

还没有评论,来说两句吧...

相关阅读