Caused by: org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [www.csdn.spring.autowire.DeptBean] is defined: expected single matching bean but found 2: deptBean,deptBean1
这两种错误原因:都是spring配置文件中自动装配按byType时出的问题,配置文件, 红色部分为错误的解释和导致错误的原因如下:
9. 错误九
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'empBean' defined in class path resource [spring-byConstructor.xml]: Unsatisfied dependency expressed through constructor argument with index 0 of type [www.csdn.spring.autowire.DeptBean]: : No qualifying bean of type [www.csdn.spring.autowire.DeptBean] is defined: expected single matching bean but found 2: deptBean1,deptBean2; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [www.csdn.spring.autowire.DeptBean] is defined: expected single matching bean but found 2: deptBean1,deptBean2
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray
Caused by: org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [www.csdn.spring.autowire.DeptBean] is defined: expected single matching bean but found 2: deptBean1,deptBean2
错误原因: spring配置文件中自动装配按constructor时出的问题,配置文件, 红色部分为错误的解释和导致错误的原因如下:
10. 错误十
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unexpected failure
during bean definition parsing
Offending resource: class path resource [spring-collection.xml]
Bean 'collectionBean'; nested exception is org.springframework.beans.factory.parsing.BeanDefinitionParsingException:
Configuration problem:
Offending resource: class path resource [spring-collection.xml]
Bean 'collectionBean'
-> Property 'users'
Caused by: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem:
element for property 'users' must specify a ref or value
Offending resourc