码迷,mamicode.com
首页 > 其他好文 > 详细

NoUniqueBeanDefinitionException

时间:2020-03-01 21:48:37      阅读:60      评论:0      收藏:0      [点我收藏+]

标签:pre   mat   expected   rac   table   abs   bst   matching   exp   

  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类

NoUniqueBeanDefinitionException

标签:pre   mat   expected   rac   table   abs   bst   matching   exp   

原文地址:https://www.cnblogs.com/wangyang9629/p/12392184.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!