在SpringAOP的操作运行中
出现下面的的报错
Error creating bean with name ‘T’: Unsatisfied dependency expressed through field ‘xx’;
nested exception is org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named ‘Y’ is expected to be of type ‘T’ but was actually of type ‘com.sun.proxy.$Proxy18’
的错误是因为在测试类中的@Autowired要调用的是接口
理由
JDK动态代理 创建代理对象的要求:
被代理类最少实现一个接口,如果没有则不能使用
所以在动态的增强方法中要细心,底层的一些理由不能忘