在使用Spring AOP时,遇到如下的错误:
java.lang.ClassCastException: com.sun.proxy.$Proxy11 cannot be cast to testcode.Volunteer
at testcode.aspectjTest.test1(aspectjTest.java:18)
有两个解决方法:
1、在aop:config标签上加上proxy-target-class=”true”
<aop:config proxy-target-class="true"></aop:config>
2、使用<aop:aspectj-autoproxy proxy-target-class="true"/>
配置在spring xml