Spring报错:org.springframework.beans.factory.NoUniqueBeanDefinitionException
2017-10-04 19:18
531 查看
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
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
相关文章推荐
- org.springframework.beans.factory.NoUniqueBeanDefinitionException异常问题
- org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [com.yuanv.b
- org.springframework.beans.factory.NoUniqueBeanDefinitionException (一个类2个实例对象)
- org.springframework.beans.factory.NoUniqueBeanDefinitionException 导致原因之一
- Cause:org.springframework.beans.factory.NoUniqueBeanDefinitionException
- 升级版本后报这个异常 : org.springframework.beans.factory.NoUniqueBeanDefinitionException
- Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [
- Exception in thread "main" org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qua
- Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [
- org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'xx' is defined
- FAQ(36):org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'userService'
- org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type
- org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.wan
- Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'dataSourc
- org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'xx' is defined
- org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'sessionFactory' is d
- org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.wei
- org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'XXXX' is defined
- org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'transactionManager'
- org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named '