使用spring遇到"BeanNotOfRequiredTypeException......but was actually of type [com.sun.proxy.$Proxy18]"异常

来源:互联网 发布:淘宝九块九包邮怎么弄 编辑:程序博客网 时间:2024/05/18 18:02

问题描述:


在使用aspectJ申明事务管理时出现的异常

org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'accountServiceImpl' must be of type [com.cc.spring.demo4.AccountServiceImpl],but was actually of type [com.sun.proxy.$Proxy18]



解决方法:


出现该异常是由于使用了默认的jdk的自动动态代理,需要在<aop:aspectj-autoproxy中添加proxy-target-class="true"   如下:<aop:aspectj-autoproxy  proxy-target-class="true"/> ,即表示使用AspectJ的支持。



0 0