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包太老了,换成最新版本即可解决. 下载地址

 

posted @ 2019-09-09 08:57  Umbrellaox  阅读(4805)  评论(0编辑  收藏  举报