Spring AOP两个错误解决


 

1.Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sword' defined in class path resource [Demo/applicationContext.xml]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException:

#问题解决:缺少了 aspectjweaver.jar 包,下载地址

#顺便附上另一个有可能缺少的包:aopalliance-1.0.jar,下载地址

 

2.Exception in thread "main" java.lang.ClassCastException: class com.sun.proxy.$Proxy11 cannot be cast to class XXX

(com.sun.proxy.$Proxy11 and Demo.BraveKnight are in unnamed module of loader 'app')

 

#报错信息:动态代理生成的类无法转换到我们自定义的实现类

#问题解决:在aop:config标签中添加 proxy-target-class="true" 即可。

 

3.<aop:aspectj-autoproxy /> 引起UnsatisfiedDependencyException问题解决;

#解决方法:aspectjweaver包太老了,换成最新版本即可解决. 下载地址

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM