Spring报错:org.springframework.beans.factory.NoUniqueBeanDefinitionException

来源:互联网 发布:php旅游网站模板 编辑:程序博客网 时间:2024/05/21 00:21
org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [com.panpan.beans.Book] is defined: expected single matching bean but found 2: book01,book02
 at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:312)
 at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:985)
 at com.panpan.test.IOCTest.test2(IOCTest.java:37)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)


如果按照类型获取Spring组件(bean),有多个类型相同的bean都会报错,换成id获取即可,或者不要有多个类型的bean
阅读全文
0 0
原创粉丝点击