使用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)
萧十郎
相关分类