问题: expected single matching bean but found 2: xxx,xxx

原因:在 Spring 容器中配置了两个类型Bean,Spring 容器将无法确定到底要用哪一个 Bean,因此异常发生了。

解决方法: 使用 @Qualifier 注释指定注入 Bean 的名称

多数据源报错 expected single matching bean but found 2: xxx,xxx的更多相关文章

  1. Spring 3.2 @Autowired异常:expected single matching bean but found 2

    在使用Sping做单元测试时候,对RequestMappingHandlerAdapter(从处理器包装过来的适配器)进行自动装配, 发现报:expected single matching bean ...

  2. 多个@bean无法通过@resource注入对应的bean(org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'javax.sql.DataSource' available: expected single matching bean but found )

    一.异常 org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type ' ...

  3. MyBatis Plus:No qualifying bean of type 'com.baomidou.mybatisplus.mapper.BaseMapper<?>' available: expected single matching bean but found 4

    场景: 应用MyBatis Plus 和通用Mapper 继承自ServiceImpl实现对Service里的方法进行包装再处理. public interface IServiceBase2< ...

  4. Spring Boot 自定义配置文件异常"expected single matching bean but found 2"

    运行环境:Spring Boot 2.5.0, IDEA 2020.3.2 异常详细信息: Injection of resource dependencies failed; nested exce ...

  5. spring " expected single matching bean but found 2" 问题一例。

    初入java,使用spring时遇到一个问题,左边是一个接口和实现.右边是service和实现. @Service@Transactional(rollbackFor = Exception.clas ...

  6. spring依赖注入单元测试:expected single matching bean but found 2

    异常信息:org.springframework.beans.factory.UnsatisfiedDependencyException: Caused by: org.springframewor ...

  7. expected single matching bean but found 2

    org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'acc ...

  8. 深入Spring Boot:怎样排查expected single matching bean but found 2的异常

    写在前面 这个demo来说明怎么排查一个常见的spring expected single matching bean but found 2的异常. https://github.com/hengy ...

  9. expected single matching bean but found 2: menusServiceImpl,IMenusService

    问题如下: 接口也作为匹配的bean? 有点迷惑了....... 经过在网上找资料,发现和@MapperScan这个注解有关系,具体源码不止.但是这个注解会扫描路径下的所有类. 去掉这个注解就可以正常 ...

随机推荐

  1. PHP操作MySQL数据库步骤:

    简单的PHP操作数据库步骤: 1.连接数据库     $con = mysql_connect('ip','username','password'); 2.选择数据库   mysql_select_ ...

  2. ArrayDeque解析

    Queue接口 public abstract boolean add(E paramE); public abstract boolean offer(E paramE); // 加入元素 publ ...

  3. 常用工具说明-- Intellij Idea生成JavaDoc

    JavaDoc是一种将注释生成HTML文档的技术,生成的HTML文档类似于Java的API,易读且清晰明了.在简略介绍JavaDoc写法之后,再看一下在Intellij Idea 中如何将代码中的注释 ...

  4. 19.Decorator修饰器

    Decorator 修饰器 类的修饰 许多面向对象的语言都有修饰器(Decorator)函数,用来修改类的行为.目前,有一个提案将这项功能,引入了 ECMAScript. @testable clas ...

  5. [转]Configure Network Drive Visible for SQL Server During Backup and Restore Using SSMS

    本文转自:https://mytechmantra.com/LearnSQLServer/Configure-Network-Drive-Visible-for-SQL-Server-During-B ...

  6. BG.Hadoop.Master

    1. 安装JDK JDK安装包复制到/opt文件夹 cd /opt rpm -ivh jdk-8u121-linux-x64.rpm vim /etc/profile 增加 JAVA_HOME=/us ...

  7. Jsp&Servlet入门级项目全程实录第7讲

    惯例广告一发,对于初学真,真的很有用www.java1234.com,去试试吧! 1.获取搜索条件值 function searchStudent(){ $('#dg').datagrid('load ...

  8. 利用SignalR来同步更新Winfrom小试

    之前写了个用Socket来更新多个Winfrom的试例,这两天看了下SignalR,也用这个来试一下 SignalR 地址:https://www.asp.net/signalr 我这个也是基于 ht ...

  9. Java基础教程(9)--流程控制

    一.分支结构 1.if语句   if语句会与其后的第一条语句或代码块结合,且只有当判断条件为true时才执行语句或代码块.例如,自行车只有在运动的时候才可以减速,就像下面这样: void applyB ...

  10. commons-fileupload-1.4使用及问题

    文件上传 使用commons-fileupload-1.4控件及依赖的commons-io-2.6控件 jsp页面中内容 <form action="../servlet/FileUp ...