问题:org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'goodsFacadeImpl' is expected to be of type 'com.dada.base.facade.GoodsFacadeImpl' but was actually of type 'com.sun.proxy.$Proxy22'
产生原因:由于JDK的动态代理不支持类注入,只支持接口注入
解决方法:
1、 修改代码,统一使用接口注入,不使用类注入;
2、 使用CGLib代理;
3、 在Spring的AOP配置中添加如下配置,使Spring代理目标类:
<aop:config proxy-target-class="true">
proxy-target-class属性有两个值:true或者false。默认状态下,proxy-target-class属性的值为false,那么被代理类是基于javaSE(JDK)的动态代理(一般被代理类会实现接口);如果显式的设置了proxy-target-class属性的值为true,那么被代理类就将基于cglib动态代理(spring框架中的代理)。