org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'UserTest': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'StudentServiceImpl' is expected to be of type 'com.coolway.service.impl.StudentServiceImpl' but was actually of type 'com.sun.proxy.$Proxy21'
原因:aop代理混用,看到proxy我们就应当知道是代理出了问题
解决方法:
在</aop:config> 后配置一行<aop:aspectj-autoproxy proxy-target-class="true"/>
这个配置的作用是强制spring使用cglib代理方式,而不是jdk方式
<aop:aspectj-autoproxy proxy-target-class="true"/>
更多推荐
初学spring报错-....but was actually of type ‘com.sun.proxy.$Proxy**‘
发布评论