当前位置: 代码迷 >> 综合 >> 【BugFix】Injection of autowired dependencies failed;Could not autowire field AOP代理类 + @Autowired注入 报错
  详细解决方案

【BugFix】Injection of autowired dependencies failed;Could not autowire field AOP代理类 + @Autowired注入 报错

热度:45   发布时间:2023-12-22 01:47:09.0

1.现象

项目启动不了,报 Could not autowire field, No qualifying bean of type [xxx] found for dependency

2.原因

autowire自动装配的字段类型声明的是实现类 xxximp  extends xxx

由于xxx类命中了切面,导致spring暴露出来的是代理类,而JDK动态代理生成的对象 的类是面向接口的,对于实现类无感知,

所以报错

3.解决方案

依赖字段的类型 面向接口编程,类型改为对应接口

  相关解决方案