为了账号安全,请及时绑定邮箱和手机立即绑定

spring aop 注解报错

spring aop 注解报错

长风秋雁 2019-03-12 13:15:02
使用Spring aop实现一个小例子,依赖注入使用注解实现,但是总是报错,信息如下:严重: Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener@4df828d7] to prepare test instance [com.zkzong.springinaction.springidol.AopAnnoTest@5e01a982]org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'com.zkzong.springinaction.springidol.AopAnnoTest': Unsatisfied dependency expressed through field 'performer': Bean named 'instrumentalistAnno' is expected to be of type [com.zkzong.springinaction.springidol.InstrumentalistAnno] but was actually of type [com.sun.proxy.$Proxy15]; nested exception is org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'instrumentalistAnno' is expected to be of type [com.zkzong.springinaction.springidol.InstrumentalistAnno] but was actually of type [com.sun.proxy.$Proxy15]    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:569)    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:349)    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireBeanProperties(AbstractAutowireCapableBeanFactory.java:385)    at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:118)    at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:83)
查看完整描述

2 回答

?
萧十郎

TA贡献1815条经验 获得超13个赞

注入的类型不对,请检查一下类的派生关系


查看完整回答
反对 回复 2019-04-24
  • 2 回答
  • 0 关注
  • 715 浏览

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号