运用spring时出现org.springframework.beans.factory.BeanNotOfRequiredTypeException: 错误
2017-06-15 16:36
716 查看
错误信息:
Caused by: org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'studentService' is expected to be of type [com.ddp.service.spring.StudentService] but was actually of type [org.springframework.aop.aspectj.AspectJExpressionPointcut]
网上解决方案:
1.使用aop配置:
<aop:config proxy-target-class="false"> </aop:config>
2. aspectj配置:
<aop:aspectj-autoproxy proxy-target-class="true"/>
3. 事务annotation配置:
<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/
自己试了一下,结果还是不能解决自己的问题,网上说的什么接口注入,类注入,jdk动态代理,cglib代理倒是理解并表示赞同,奈何此处发生的错误原因主要在于最后一句but was actually of type [org.springframework.aop.aspectj.AspectJExpressionPointcut],此句话说明本来我们是想引用我们业务类里面的'studentService',结果实际引用的是org.springframework.aop.aspectj.AspectJExpressionPointcut里面的'studentService',也就是说我们在定义AOP的时候,它的ID也是'studentService',和我们的业务类一模一样,故此引用错了,回头找了找我的bean文件,发现果然是这个问题,改之,解决
Caused by: org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'studentService' is expected to be of type [com.ddp.service.spring.StudentService] but was actually of type [org.springframework.aop.aspectj.AspectJExpressionPointcut]
网上解决方案:
1.使用aop配置:
<aop:config proxy-target-class="false"> </aop:config>
2. aspectj配置:
<aop:aspectj-autoproxy proxy-target-class="true"/>
3. 事务annotation配置:
<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/
自己试了一下,结果还是不能解决自己的问题,网上说的什么接口注入,类注入,jdk动态代理,cglib代理倒是理解并表示赞同,奈何此处发生的错误原因主要在于最后一句but was actually of type [org.springframework.aop.aspectj.AspectJExpressionPointcut],此句话说明本来我们是想引用我们业务类里面的'studentService',结果实际引用的是org.springframework.aop.aspectj.AspectJExpressionPointcut里面的'studentService',也就是说我们在定义AOP的时候,它的ID也是'studentService',和我们的业务类一模一样,故此引用错了,回头找了找我的bean文件,发现果然是这个问题,改之,解决
相关文章推荐
- "org.springframework.beans.factory.BeanNotOfRequiredTypeException……" 错误解决方案
- org.springframework.beans.factory.BeanNotOfRequiredTypeException 错误,
- org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'faceAction' must be of
- 【异常篇-spring】org.springframework.beans.factory.BeanNotOfRequiredTypeException
- org.springframework.beans.factory.BeanNotOfRequiredTypeException
- org.springframework.beans.factory.BeanNotOfRequiredTypeException must be of type
- 代理及注入之org.springframework.beans.factory.BeanNotOfRequiredTypeException
- 异常:org.springframework.beans.factory.BeanNotOfRequiredTypeException
- org.springframework.beans.factory.BeanNotOfRequiredTypeException:
- Spring-org.springframework.beans.factory.BeanNotOfRequiredTypeException
- org.springframework.beans.factory.BeanNotOfRequiredTypeException
- org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named "" must be of type [org.apache.struts.action.Action
- Caused by: org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'dao' is exp
- 解决: org.springframework.beans.factory.BeanNotOfRequiredTypeException
- Aurora-hec4.0_scaninvoice_异常_04_org.springframework.beans.factory.BeanNotOfRequiredTypeException
- org.springframework.beans.factory.BeanNotOfRequiredTypeException:
- 处理异常:org.springframework.beans.factory.BeanNotOfRequiredTypeException
- org.springframework.beans.factory.BeanNotOfRequiredTypeException的解决办法
- 在使用Spring AOP 时,启动服务抛出异常: org.springframework.beans.factory.BeanNotOfRequiredTypeException
- shiro错误 org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type