`

@Autowired 时的异常

阅读更多
14:53:41,390 ERROR TestContextManager:258 - Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener@1465ca2] to prepare test instance [com.wangyu.manager.impl.OrgnizationManagerImplTest@6bba64]
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.wangyu.manager.impl.OrgnizationManagerImplTest': Autowiring of fields failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.wangyu.manager.impl.OrgnizationManagerImpl com.wangyu.manager.impl.OrgnizationManagerImplTest.orgnizationManager; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [com.wangyu.manager.impl.OrgnizationManagerImpl] is defined: Unsatisfied dependency of type [class com.wangyu.manager.impl.OrgnizationManagerImpl]: expected at least 1 matching bean
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessAfterInstantiation(AutowiredAnnotationBeanPostProcessor.java:243)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:959)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireBeanProperties(AbstractAutowireCapableBeanFactory.java:329)
	at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:110)
	at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75)
	at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:255)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:111)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.invokeTestMethod(SpringJUnit4ClassRunner.java:148)
	at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:59)
	at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:52)
	at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:34)
	at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:44)
	at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:50)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:97)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.wangyu.manager.impl.OrgnizationManagerImpl com.wangyu.manager.impl.OrgnizationManagerImplTest.orgnizationManager; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [com.wangyu.manager.impl.OrgnizationManagerImpl] is defined: Unsatisfied dependency of type [class com.wangyu.manager.impl.OrgnizationManagerImpl]: expected at least 1 matching bean
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:435)
	at org.springframework.beans.factory.annotation.InjectionMetadata.injectFields(InjectionMetadata.java:105)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessAfterInstantiation(AutowiredAnnotationBeanPostProcessor.java:240)
	... 19 more
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [com.wangyu.manager.impl.OrgnizationManagerImpl] is defined: Unsatisfied dependency of type [class com.wangyu.manager.impl.OrgnizationManagerImpl]: expected at least 1 matching bean
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:613)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:412)
	... 21 more




你的OrgnizationManagerImpl必须以@Service或@Component注解才行。


15:51:13,265 ERROR TestContextManager:258 - Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener@17e60a1] to prepare test instance [com.wangyu.manager.impl.OrgnizationManagerImplTest@1f9f0f2]
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.wangyu.manager.impl.OrgnizationManagerImplTest': Autowiring of fields failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.wangyu.manager.impl.OrgnizationManagerImpl com.wangyu.manager.impl.OrgnizationManagerImplTest.orgnizationManager; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [com.wangyu.manager.impl.OrgnizationManagerImpl] is defined: Unsatisfied dependency of type [class com.wangyu.manager.impl.OrgnizationManagerImpl]: expected at least 1 matching bean
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessAfterInstantiation(AutowiredAnnotationBeanPostProcessor.java:243)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:959)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireBeanProperties(AbstractAutowireCapableBeanFactory.java:329)
	at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:110)
	at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75)
	at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:255)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:111)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.invokeTestMethod(SpringJUnit4ClassRunner.java:148)
	at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
	at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
	at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
	at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
	at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:97)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.wangyu.manager.impl.OrgnizationManagerImpl com.wangyu.manager.impl.OrgnizationManagerImplTest.orgnizationManager; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [com.wangyu.manager.impl.OrgnizationManagerImpl] is defined: Unsatisfied dependency of type [class com.wangyu.manager.impl.OrgnizationManagerImpl]: expected at least 1 matching bean
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:435)
	at org.springframework.beans.factory.annotation.InjectionMetadata.injectFields(InjectionMetadata.java:105)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessAfterInstantiation(AutowiredAnnotationBeanPostProcessor.java:240)
	... 19 more
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [com.wangyu.manager.impl.OrgnizationManagerImpl] is defined: Unsatisfied dependency of type [class com.wangyu.manager.impl.OrgnizationManagerImpl]: expected at least 1 matching bean
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:613)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:412)
	... 21 more
15:51:13,359 ERROR TestContextManager:258 - Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener@17e60a1] to prepare test instance [com.wangyu.manager.impl.OrgnizationManagerImplTest@1d4eeb5]
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.wangyu.manager.impl.OrgnizationManagerImplTest': Autowiring of fields failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.wangyu.manager.impl.OrgnizationManagerImpl com.wangyu.manager.impl.OrgnizationManagerImplTest.orgnizationManager; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [com.wangyu.manager.impl.OrgnizationManagerImpl] is defined: Unsatisfied dependency of type [class com.wangyu.manager.impl.OrgnizationManagerImpl]: expected at least 1 matching bean
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessAfterInstantiation(AutowiredAnnotationBeanPostProcessor.java:243)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:959)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireBeanProperties(AbstractAutowireCapableBeanFactory.java:329)
	at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:110)
	at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75)
	at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:255)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:111)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.invokeTestMethod(SpringJUnit4ClassRunner.java:148)
	at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
	at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
	at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
	at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
	at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:97)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.wangyu.manager.impl.OrgnizationManagerImpl com.wangyu.manager.impl.OrgnizationManagerImplTest.orgnizationManager; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [com.wangyu.manager.impl.OrgnizationManagerImpl] is defined: Unsatisfied dependency of type [class com.wangyu.manager.impl.OrgnizationManagerImpl]: expected at least 1 matching bean
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:435)
	at org.springframework.beans.factory.annotation.InjectionMetadata.injectFields(InjectionMetadata.java:105)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessAfterInstantiation(AutowiredAnnotationBeanPostProcessor.java:240)
	... 19 more
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [com.wangyu.manager.impl.OrgnizationManagerImpl] is defined: Unsatisfied dependency of type [class com.wangyu.manager.impl.OrgnizationManagerImpl]: expected at least 1 matching bean
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:613)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:412)
	... 21 more
15:51:13,375 ERROR TestContextManager:258 - Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener@17e60a1] to prepare test instance [com.wangyu.manager.impl.OrgnizationManagerImplTest@83e35b]
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.wangyu.manager.impl.OrgnizationManagerImplTest': Autowiring of fields failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.wangyu.manager.impl.OrgnizationManagerImpl com.wangyu.manager.impl.OrgnizationManagerImplTest.orgnizationManager; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [com.wangyu.manager.impl.OrgnizationManagerImpl] is defined: Unsatisfied dependency of type [class com.wangyu.manager.impl.OrgnizationManagerImpl]: expected at least 1 matching bean
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessAfterInstantiation(AutowiredAnnotationBeanPostProcessor.java:243)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:959)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireBeanProperties(AbstractAutowireCapableBeanFactory.java:329)
	at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:110)
	at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75)
	at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:255)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:111)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.invokeTestMethod(SpringJUnit4ClassRunner.java:148)
	at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
	at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
	at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
	at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
	at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:97)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.wangyu.manager.impl.OrgnizationManagerImpl com.wangyu.manager.impl.OrgnizationManagerImplTest.orgnizationManager; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [com.wangyu.manager.impl.OrgnizationManagerImpl] is defined: Unsatisfied dependency of type [class com.wangyu.manager.impl.OrgnizationManagerImpl]: expected at least 1 matching bean
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:435)
	at org.springframework.beans.factory.annotation.InjectionMetadata.injectFields(InjectionMetadata.java:105)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessAfterInstantiation(AutowiredAnnotationBeanPostProcessor.java:240)
	... 19 more
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [com.wangyu.manager.impl.OrgnizationManagerImpl] is defined: Unsatisfied dependency of type [class com.wangyu.manager.impl.OrgnizationManagerImpl]: expected at least 1 matching bean
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:613)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:412)
	... 21 more
15:51:13,437 ERROR TestContextManager:258 - Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener@17e60a1] to prepare test instance [com.wangyu.manager.impl.OrgnizationManagerImplTest@c378f6]
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.wangyu.manager.impl.OrgnizationManagerImplTest': Autowiring of fields failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.wangyu.manager.impl.OrgnizationManagerImpl com.wangyu.manager.impl.OrgnizationManagerImplTest.orgnizationManager; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [com.wangyu.manager.impl.OrgnizationManagerImpl] is defined: Unsatisfied dependency of type [class com.wangyu.manager.impl.OrgnizationManagerImpl]: expected at least 1 matching bean
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessAfterInstantiation(AutowiredAnnotationBeanPostProcessor.java:243)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:959)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireBeanProperties(AbstractAutowireCapableBeanFactory.java:329)
	at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:110)
	at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75)
	at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:255)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:111)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.invokeTestMethod(SpringJUnit4ClassRunner.java:148)
	at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
	at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
	at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
	at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
	at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:97)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.wangyu.manager.impl.OrgnizationManagerImpl com.wangyu.manager.impl.OrgnizationManagerImplTest.orgnizationManager; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [com.wangyu.manager.impl.OrgnizationManagerImpl] is defined: Unsatisfied dependency of type [class com.wangyu.manager.impl.OrgnizationManagerImpl]: expected at least 1 matching bean
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:435)
	at org.springframework.beans.factory.annotation.InjectionMetadata.injectFields(InjectionMetadata.java:105)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessAfterInstantiation(AutowiredAnnotationBeanPostProcessor.java:240)
	... 19 more
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [com.wangyu.manager.impl.OrgnizationManagerImpl] is defined: Unsatisfied dependency of type [class com.wangyu.manager.impl.OrgnizationManagerImpl]: expected at least 1 matching bean
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:613)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:412)
	... 21 more
15:51:13,453 ERROR TestContextManager:258 - Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener@17e60a1] to prepare test instance [com.wangyu.manager.impl.OrgnizationManagerImplTest@13a83cc]
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.wangyu.manager.impl.OrgnizationManagerImplTest': Autowiring of fields failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.wangyu.manager.impl.OrgnizationManagerImpl com.wangyu.manager.impl.OrgnizationManagerImplTest.orgnizationManager; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [com.wangyu.manager.impl.OrgnizationManagerImpl] is defined: Unsatisfied dependency of type [class com.wangyu.manager.impl.OrgnizationManagerImpl]: expected at least 1 matching bean
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessAfterInstantiation(AutowiredAnnotationBeanPostProcessor.java:243)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:959)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireBeanProperties(AbstractAutowireCapableBeanFactory.java:329)
	at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:110)
	at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75)
	at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:255)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:111)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.invokeTestMethod(SpringJUnit4ClassRunner.java:148)
	at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
	at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
	at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
	at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
	at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:97)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.wangyu.manager.impl.OrgnizationManagerImpl com.wangyu.manager.impl.OrgnizationManagerImplTest.orgnizationManager; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [com.wangyu.manager.impl.OrgnizationManagerImpl] is defined: Unsatisfied dependency of type [class com.wangyu.manager.impl.OrgnizationManagerImpl]: expected at least 1 matching bean
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:435)
	at org.springframework.beans.factory.annotation.InjectionMetadata.injectFields(InjectionMetadata.java:105)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessAfterInstantiation(AutowiredAnnotationBeanPostProcessor.java:240)
	... 19 more
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [com.wangyu.manager.impl.OrgnizationManagerImpl] is defined: Unsatisfied dependency of type [class com.wangyu.manager.impl.OrgnizationManagerImpl]: expected at least 1 matching bean
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:613)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:412)
	... 21 more
15:51:13,453 ERROR TestContextManager:258 - Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener@17e60a1] to prepare test instance [com.wangyu.manager.impl.OrgnizationManagerImplTest@a2d304]
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.wangyu.manager.impl.OrgnizationManagerImplTest': Autowiring of fields failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.wangyu.manager.impl.OrgnizationManagerImpl com.wangyu.manager.impl.OrgnizationManagerImplTest.orgnizationManager; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [com.wangyu.manager.impl.OrgnizationManagerImpl] is defined: Unsatisfied dependency of type [class com.wangyu.manager.impl.OrgnizationManagerImpl]: expected at least 1 matching bean
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessAfterInstantiation(AutowiredAnnotationBeanPostProcessor.java:243)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:959)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireBeanProperties(AbstractAutowireCapableBeanFactory.java:329)
	at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:110)
	at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75)
	at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:255)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:111)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.invokeTestMethod(SpringJUnit4ClassRunner.java:148)
	at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
	at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
	at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
	at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
	at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:97)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.wangyu.manager.impl.OrgnizationManagerImpl com.wangyu.manager.impl.OrgnizationManagerImplTest.orgnizationManager; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [com.wangyu.manager.impl.OrgnizationManagerImpl] is defined: Unsatisfied dependency of type [class com.wangyu.manager.impl.OrgnizationManagerImpl]: expected at least 1 matching bean
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:435)
	at org.springframework.beans.factory.annotation.InjectionMetadata.injectFields(InjectionMetadata.java:105)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessAfterInstantiation(AutowiredAnnotationBeanPostProcessor.java:240)
	... 19 more
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [com.wangyu.manager.impl.OrgnizationManagerImpl] is defined: Unsatisfied dependency of type [class com.wangyu.manager.impl.OrgnizationManagerImpl]: expected at least 1 matching bean
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:613)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:412)
	... 21 more
15:51:13,468  INFO GenericApplicationContext:815 - Closing org.springframework.context.support.GenericApplicationContext@1c86be5: display name [org.springframework.context.support.GenericApplicationContext@1c86be5]; startup date [Fri Feb 20 15:51:05 CST 2009]; root of context hierarchy
15:51:13,468  INFO DefaultListableBeanFactory:421 - Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@165c7f6: defining beans [userBean,annotationPropertyConfigurer,dataSource,sessionFactory,transactionManager,txAdvice,org.springframework.aop.config.internalAutoProxyCreator,allManagerMethod,org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor#0,orgnizationManagerImpl,securityManager,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,userDAO,orgnizationDAO,userManager,loggerListener,_authenticationManager,_filterChainProxy,_httpSessionContextIntegrationFilter,_filterChainProxyPostProcessor,_filterChainList,_securityContextHolderAwareRequestFilter,_accessManager,_portMapper,_exceptionTranslationFilter,_filterSecurityInterceptor,_sessionFixationProtectionFilter,_logoutFilter,_basicAuthenticationEntryPoint,_basicAuthenticationFilter,_formLoginFilter,_formLoginEntryPoint,_entryPointInjectionBeanPostProcessor,_userServiceInjectionPostProcessor,org.springframework.security.providers.dao.DaoAuthenticationProvider#0,org.springframework.security.config.AuthenticationProviderBeanDefinitionParser$AuthenticationProviderCacheResolver#0,accessDecisionManager,resourceSecurityInterceptor,secureResourceFilterInvocationDefinitionSource]; root of factory hierarchy
5328 [Thread-5] INFO org.hibernate.impl.SessionFactoryImpl - closing
15:51:13,531  INFO AnnotationSessionFactoryBean:246 - Closing Hibernate SessionFactory


自动写入的时候把接口写成实现类了
@Autowired
private OrgnizationManagerImpl orgnizationManager;
应该是
@Autowired
private IOrgnizationManager orgnizationManager;
分享到:
评论

相关推荐

    SSH笔记-通过@Autowired配置注入关系

    在使用`@Autowired`时,有以下几个关键点需要注意: 1. **类型匹配**:默认情况下,Spring通过类型来查找匹配的Bean。例如,如果一个类有一个类型为`UserService`的属性,并且容器中有至少一个`UserService`类型的...

    (转)Spring中@Autowired注解和@Resource注解的区别

    在阅读《Spring中Autowired和Resource的区别.docx》文档时,可以深入探讨这两个注解的内部实现原理,以及在实际项目中的最佳实践。通过源码分析,我们可以了解到Spring如何解析这些注解并执行依赖注入的过程,这有助...

    Spring@Autowired注解与自动装配.rar

    - **字段注入**:直接在成员变量上使用`@Autowired`,Spring会在初始化时注入对应的bean。 ```java @Autowired private MyService myService; ``` - **方法注入**:可以在setter方法或带有参数的方法上使用`@...

    Spring注解@Resource和@Autowired.doc

    因此,在选择使用@Resource 或@Autowired 时,需要考虑到具体的使用场景。如果需要按照名称装配,可以使用@Resource,如果需要按照类型装配,可以使用@Autowired。同时,需要注意它们的装配顺序和使用策略,以免出现...

    @Autowired 注解是如何实现的?(csdn)————程序.pdf

    当Spring扫描带有`@Autowired`注解的字段、构造函数或方法时,它会执行以下步骤: 1. **候选Bean的查找**:Spring会根据目标类型(如`MovieCatalog`)在`BeanFactory`中搜索Bean。如果提供了`@Qualifier`注解,那么...

    Intellij IDEA如何去掉@Autowired 注入警告的方法

    当我们在Service层注入Mybatis的Mapper时,我们通常会使用@Autowired 自动注入。但是,这时候Intellij IDEA会显示红色告警,提示不能自动注入。这是因为IDEA可以识别并理解Spring的上下文,但是Mapper接口是Mybatis...

    12 @Autowired是如何工作的?-Spring注解源码深度揭秘-慕课专栏1

    `@Autowired`的`@Retention`设置为`RetentionPolicy.RUNTIME`,意味着该注解会在运行时仍然有效,允许在运行时通过反射等机制访问和处理注解信息。这样,Spring容器在初始化时可以通过反射获取到`@Autowired`注解,...

    Spring @Autowired

    当遇到`@Autowired`注解时,Spring会通过`AutowiredAnnotationBeanPostProcessor`进行处理,它实现了`BeanPostProcessor`接口,负责在Bean实例化之后进行后处理,包括依赖注入。 ### 8. 实战示例 在`...

    Spring的Autowired自动装配(XML版本+Annotation版本+源码+解析)

    当Spring容器初始化时,会扫描所有带有@Autowired的注解,然后通过BeanPostProcessor接口进行后处理,实现依赖注入。 这个过程大致分为以下几步: 1. 找到带有@Autowired的字段、方法或构造器。 2. 根据注解的配置...

    详解SpringBoot 多线程处理任务 无法@Autowired注入bean问题解决

    但是在多线程处理任务中,当我们使用 @Autowired 注入 bean 时,会出现空指针异常。这是为什么呢? 原因分析: 在 SpringBoot 应用程序中,bean 的注入是通过 ApplicationContext 来实现的。在多线程处理任务中,每...

    学习Spring笔记_Annotation(注解)_Autowired_Qualifier

    `@Autowired`注解还支持一些可选属性,例如`required`(默认为true,表示必须注入,否则抛出异常),以及`@Autowired`可以应用于字段、构造器、方法和参数级别,提供了灵活的注入方式。 除了`@Autowired`,Spring...

    你所不知道的Spring的@Autowired实现细节分析

    总结,`@Autowired`的实现涉及到Spring Bean生命周期中的多个阶段,包括BeanPostProcessor的回调、构造函数的选择、依赖匹配和异常处理等。理解这些细节对于优化Spring应用的依赖管理以及排查相关问题至关重要。通过...

    Spring框架中 @Autowired 和 @Resource 注解的区别

    当在字段或方法上使用`@Autowired`时,Spring会查找与该字段或方法参数类型相匹配的Bean,并将其注入。如果找到多个匹配的Bean,可以通过提供`@Qualifier`注解来指定特定的Bean。如果没有任何匹配的Bean,Spring会抛...

    解决Springboot @Autowired 无法注入问题

    4. `@Autowired`的可选性:默认情况下,`@Autowired`是非必需的,如果找不到匹配的bean,Spring会抛出异常。你可以通过设置`@Autowired(required=false)`让它成为可选的。 5. Spring配置问题:检查`application....

    spring的annotation的autowired

    默认情况下,`@Autowired`是基于类型的,即Spring会查找与目标类型匹配的Bean,如果找到了就注入,如果没有找到则抛出异常。 ### 2. 使用方法 #### 2.1 基于类型的自动装配 在字段、构造函数、方法或参数级别上...

    spring中Autowired和Qulifier注解

    然而,当存在多个相同类型的Bean时,`@Autowired`可能无法准确地确定哪个Bean应该被注入。这时,我们就需要用到`@Qualifier`注解来指定具体的Bean。`@Qualifier`允许你通过Bean的名字来精确地选择需要注入的实例。 ...

    spring autowired注解完整版

    例如,如果有多个实现了同一个接口的 Bean,Spring 将无法确定注入哪一个,这时可能会抛出异常。 2. **@Qualifier**:当存在多个候选 Bean 时,可以通过 @Qualifier 注解指定具体要注入哪个 Bean。例如,在上面的...

    javaSpring注解入门[参考].pdf

    在上面的例子中,如果当Spring上下文中存在不止一个UserDao类型的bean时,就会抛出BeanCreationException异常;如果Spring上下文中不存在UserDao类型的bean,也会抛出BeanCreationException异常。我们可以使用@...

    Spring 注解 入门

    例如,在`UserManagerImpl`类中,我们可以通过在`userDao`字段上添加`@Autowired`,让Spring在实例化`UserManagerImpl`时自动寻找并注入`UserDao`类型的bean。如果注解在方法上,如`setUserDao`,Spring会在初始化...

Global site tag (gtag.js) - Google Analytics