spring中编写aop是遇见的问题

四月 22, 2018 10:55:40 上午 org.springframework.test.context.support.DefaultTestContextBootstrapper getDefaultTestExecutionListenerClassNames
信息: Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener]
四月 22, 2018 10:55:40 上午 org.springframework.test.context.support.DefaultTestContextBootstrapper getTestExecutionListeners
信息: Using TestExecutionListeners: [org.springframework.test.context.web.ServletTestExecutionListener@5315b42e, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener@2ef9b8bc, org.springframework.test.context.support.DependencyInjectionTestExecutionListener@5d624da6, org.springframework.test.context.support.DirtiesContextTestExecutionListener@1e67b872, org.springframework.test.context.transaction.TransactionalTestExecutionListener@60addb54, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener@3f2a3a5]
四月 22, 2018 10:55:40 上午 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
信息: Loading XML bean definitions from class path resource [applicationContext.xml]
四月 22, 2018 10:55:40 上午 org.springframework.context.support.GenericApplicationContext prepareRefresh
信息: Refreshing org.springframework.context.support.GenericApplicationContext@4520ebad: startup date [Sun Apr 22 10:55:40 CST 2018]; root of context hierarchy
四月 22, 2018 10:55:40 上午 org.springframework.test.context.TestContextManager prepareTestInstance
严重: Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener@5d624da6] to prepare test instance [demo2.test@149e0f5d]
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'demo2.test': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private demo2.CustomerDao demo2.test.customerDao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customerDaoProxy': FactoryBean threw exception on object creation; nested exception is org.springframework.aop.framework.AopConfigException: Unknown advisor type class demo2.CustomerDaoImpl; Can only include Advisor or Advice type beans in interceptorNames chain except for last entry,which may also be target or TargetSource; nested exception is org.springframework.aop.framework.adapter.UnknownAdviceTypeException: Advice object [demo2.CustomerDaoImpl@47d90b9e] is neither a supported subinterface of [org.aopalliance.aop.Advice] nor an [org.springframework.aop.Advisor]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
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)
at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:228)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:217)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:276)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:278)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:236)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:87)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:180)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private demo2.CustomerDao demo2.test.customerDao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customerDaoProxy': FactoryBean threw exception on object creation; nested exception is org.springframework.aop.framework.AopConfigException: Unknown advisor type class demo2.CustomerDaoImpl; Can only include Advisor or Advice type beans in interceptorNames chain except for last entry,which may also be target or TargetSource; nested exception is org.springframework.aop.framework.adapter.UnknownAdviceTypeException: Advice object [demo2.CustomerDaoImpl@47d90b9e] is neither a supported subinterface of [org.aopalliance.aop.Advice] nor an [org.springframework.aop.Advisor]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:571)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
... 26 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customerDaoProxy': FactoryBean threw exception on object creation; nested exception is org.springframework.aop.framework.AopConfigException: Unknown advisor type class demo2.CustomerDaoImpl; Can only include Advisor or Advice type beans in interceptorNames chain except for last entry,which may also be target or TargetSource; nested exception is org.springframework.aop.framework.adapter.UnknownAdviceTypeException: Advice object [demo2.CustomerDaoImpl@47d90b9e] is neither a supported subinterface of [org.aopalliance.aop.Advice] nor an [org.springframework.aop.Advisor]
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:175)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:103)
at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1574)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:253)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:196)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1145)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1069)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:967)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:543)
... 28 more
Caused by: org.springframework.aop.framework.AopConfigException: Unknown advisor type class demo2.CustomerDaoImpl; Can only include Advisor or Advice type beans in interceptorNames chain except for last entry,which may also be target or TargetSource; nested exception is org.springframework.aop.framework.adapter.UnknownAdviceTypeException: Advice object [demo2.CustomerDaoImpl@47d90b9e] is neither a supported subinterface of [org.aopalliance.aop.Advice] nor an [org.springframework.aop.Advisor]
at org.springframework.aop.framework.ProxyFactoryBean.namedBeanToAdvisor(ProxyFactoryBean.java:593)
at org.springframework.aop.framework.ProxyFactoryBean.addAdvisorOnChainCreation(ProxyFactoryBean.java:549)
at org.springframework.aop.framework.ProxyFactoryBean.initializeAdvisorChain(ProxyFactoryBean.java:467)
at org.springframework.aop.framework.ProxyFactoryBean.getObject(ProxyFactoryBean.java:244)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:168)
... 36 more
Caused by: org.springframework.aop.framework.adapter.UnknownAdviceTypeException: Advice object [demo2.CustomerDaoImpl@47d90b9e] is neither a supported subinterface of [org.aopalliance.aop.Advice] nor an [org.springframework.aop.Advisor]
at org.springframework.aop.framework.adapter.DefaultAdvisorAdapterRegistry.wrap(DefaultAdvisorAdapterRegistry.java:62)
at org.springframework.aop.framework.ProxyFactoryBean.namedBeanToAdvisor(ProxyFactoryBean.java:588)
... 40 more


四月 22, 2018 10:55:40 上午 org.springframework.context.support.GenericApplicationContext doClose

信息: Closing org.springframework.context.support.GenericApplicationContext@4520ebad: startup date [Sun Apr 22 10:55:40 CST 2018]; root of context hierarchy

问题:

解决方法:value应该为增强类的key值

猜你喜欢

转载自blog.csdn.net/qq_40036979/article/details/80037071