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

来源:互联网 发布:vr转换软件 电脑 编辑:程序博客网 时间:2024/04/29 04:14

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

0 0
原创粉丝点击