当前位置: 代码迷 >> 综合 >> The bean ‘xxxImpl‘ could not be injected as a ‘xxx‘because it is a JDK dynamic proxy that implements
  详细解决方案

The bean ‘xxxImpl‘ could not be injected as a ‘xxx‘because it is a JDK dynamic proxy that implements

热度:27   发布时间:2023-12-13 08:47:41.0

当启动项目时出现以下通用情况

The bean ‘xxxImpl’ could not be injected as a 'xxx’because it is a JDK dynamic proxy that implements

错误定位

在这里插入图片描述

解决

  • 理由:一般都会使用接口进行注入,如果存在多个实现类的话可以指定注入名称。

动态代理的模式是根据接口注入,需要类实现接口,spring在处理这些注解的时候肯定是通过aop这些东西,处理这些注解,aop的一种实现原理也是通过jdk的动态代理的方式,由于注入使用了实现类注入,所以改为接口注入;

在这里插入图片描述

  相关解决方案