**Bean named 'XXX' is expected but was actually of type 'com.sun.proxy.$Proxy**'的兩種解決方法**
阿新 • • 發佈:2018-11-22
but was actually of type 'com.sun.proxy.$Proxy’的兩種解決方法**
錯誤提示:
Caused by: org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'catServiceImpl' is expected to be of type 'com.xin.service.CatServiceImpl' but was actually of type 'com.sun.proxy.$Proxy17'
方法一:
<aop:config> <aop:aspect ref="TxManager"> <aop:pointcut id="txPointCut" expression="execution(* com.xin.service.*ServiceImpl.*(..))"/> <aop:before method="begin" pointcut-ref="txPointCut"/> <aop:after-throwing method="rollback" pointcut-ref="txPointCut"/> <aop:after-returning method="commit" pointcut-ref="txPointCut"/> </aop:aspect> </aop:config>
<aop:config> <aop:aspect ref="TxManager"> <aop:pointcut id="txPointCut" expression="execution(* com.xin.service.*ServiceImpl.*(..))"/> <aop:before method="begin" pointcut-ref="txPointCut"/> <aop:after-throwing method="rollback" pointcut-ref="txPointCut"/> <aop:after-returning method="commit" pointcut-ref="txPointCut"/> </aop:aspect> </aop:config> <!--新增上這句話--!> <aop:aspectj-autoproxy proxy-target-class="true"/>
我是用方法一就解決了
大佬說原因是spring aop代理混用的問題(這問題我暫時也不太懂。百度學學)
方法二:
轉自:這裡