运行 SSH 的程序报以下错误:
java.lang.ClassCastException: $Proxy11
at junit.test.bean.EmployeeTest.setUpBeforeClass(EmployeeTest.java:23)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
解决办法如下:
在spring的配置文件中加入:
<aop:aspectj-autoproxy proxy-target-class="true" />
重新运行程序,OK!!
本文介绍了解决Java程序中出现的ClassCastException的具体步骤。通过在Spring配置文件中添加特定的AOP代理配置,成功解决了单元测试过程中的异常问题。
1440

被折叠的 条评论
为什么被折叠?



