spring错误汇总 (三)

2014-11-24 11:07:19 · 作者: · 浏览: 2
ory.UnsatisfiedDependencyException: Error creating bean with name 'empBean' defined in class path resource [spring-byType.xml]: Unsatisfied dependency expressed through bean property 'deptBean': : No qualifying bean of type [www.csdn.spring.autowire.DeptBean] is defined: expected single matching bean but found 2: deptBean,deptBean1; 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: deptBean,deptBean1

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: element for property 'users' must specify a ref or value

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