Spring aop报错:com.sun.proxy.$Proxyxxx cannot be cast to yyy

在使用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

猜你喜欢

转载自blog.csdn.net/u012263493/article/details/50908865