springboot bean找不到问题

499 阅读1分钟

报错如下

onested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.fendouweiqian.yudao.study.module.system.service.user.AdminUserService' available: expected at least 1 bean which qualifies as autowire candidate.

网上解决方案 1.之前可用,配置文件没有改,启动类扫描配置没有变更 2.注解没有变更,相关引入都加入了@Autowired 3.可能是因为bean里面有相同的bean的名称 4.忘记加@Service、@Mapper等注解

以上情况可能覆盖了大部分情况。


考虑情况 但实际上是可能错误看的不完整,只盯着最上面的错误 根据上门的异常,以为是 AdminUserService bean注入出现了问题

实际上可能是 AdminUserService 里面引入的bean出了问题 查看日志往下找发现

No qualifying bean of type 'org.fendouweiqian.yudao.study.module.system.service.user.AdminUserService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations

真实原因 AdminUserService bean本身出现了问题 AdminUserService 依赖的bean失败,原因参考 网上解决方案