Spring AOP 配置须要注意的问题,CGLIBhtml
在生成aop代理类的时候,报错: Could not generate CGLIB subclass of class [class XXXX]: Common causes of this problem include using a final class or a non-visible class;java
后通过检查, 原来在spring启动aop的配置里面是这样写的spring
1 <aop:aspectj-autoproxy proxy-target-class="true"/> 编程
2<tx:annotation-driven proxy-target-class="true" transaction-manager="txManager" />
这样的状况,Spring是采用CGLIB去代理,而采用此方式代理,是不能够面向接口编程的,也就是说要代理的类不能够实现接口,并且要想正常使用貌似还要加上一个默认构造函数.ide
因此,解决这个问题,用Spring默认的代理方式就能够了,配置改为函数
1 <aop:aspectj-autoproxy/>this
2<tx:annotation-driven transaction-manager="txManager" />
就OK了.
转载自:http://www.2016k.com/programmer/java/spring/01-123.html代理