英文:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘person3’ defined in class path resource [bean-autowireE1.xml]: Unsatisfied dependency expressed through bean property ‘address’: : No qualifying bean of type [com.atguigu.spring.beans.autowireE1.Address] is defined: expected single matching bean but found 4: address,addressTest1,addressTest2,addressTest3; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [com.atguigu.spring.beans.autowireE1.Address] is defined: expected single matching bean but found 4: address,addressTest1,addressTest2,addressTest3
中文:
org.springframework.beans.factory。UnsatisfiedDependencyException:在类路径资源[bean- autowiree1]中创建名为’person3’的bean时出错。xml]:通过bean属性“address”表示的不满足的依赖关系::没有符合条件的bean类型[com.atguigu.spring.bean . autowiree1。定义:期望的单个匹配bean,但发现3:Address、addressTest1、addressTest2;嵌套异常是org.springframe .bean .factory。iquebeandefinition exception:没有符合条件的bean类型[com.atguigu.spring.beans.autowireE1]。定义了:期望的单个匹配bean,但是发现了3:Address、addressTest1、addressTest2
|
问题影响:在xml文件中,读取是从上向下进行的,有些错误如果你不注释掉,即使在后面的Java类中没有用到这段代码,它也会报错。
解决方案:1.把相应bean设置为唯一的 2.在不需要用到这段代码时,可以将其注释掉
下面这张图就是我遇到的错误,现在分享给大家,便于大家理解。
关于spring框架中,byType类型自动装配错误问题及xml中常常出现错误的小细节的陈述
最新推荐文章于 2023-08-05 15:32:17 发布