Spring常见错误(1)之NoUniqueBeanDefinitionException

  在学习Spring过程中使用类型获取对象出现以下错误:org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'com.atguigu.pojo.Person' available: expected single matching bean but found 2: p1,p2

原因分析

这是因为配置文件中有两个相同数据类型的bean对象了,不能使用类型获取对象的方式,故而最好使用获取id获取对象。

posted @ 2020-09-18 19:36  iris!  阅读(1364)  评论(0编辑  收藏  举报