NoUniqueBeanDefinitionException
Exception in thread "main" org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [com.wangyang.demo.Person] is defined: expected single matching bean but found 2: person,personTwo
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:312)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:985)
at com.wangyang.demo.TestBySpring.main(TestBySpring.java:16)
NoUniqueBeanDefinitionException:没有一个唯一的bean被找到;
Person person = context.getBean(Person.class);
使用Person.class,applicationContext中存在两个Peson类

浙公网安备 33010602011771号