Spring 3.2 @Autowired异常:expected single matching bean but found 2
在使用Sping做单元测试时候,对RequestMappingHandlerAdapter(从处理器包装过来的适配器)进行自动装配,
发现报:expected single matching bean but found 2异常,意思是需要匹配单个Bean,但是却找到两个;
我在spring-servlet.xml中的确配置了一个,不知道第二个从哪里来的,一般这种情况下可以使用@Qualifier配合@Autowired来解决这些问题;
另外我预计是因为bean没有给id属性导致的,然后我在spring-servlet.xml配置中给bean添加了一个id和需要注入的变量名称一致,这个时候正常运行了。
后续还碰到一个问题,关于Spring3.2 Controller单元测试参数的问题,会再下篇文章中给出整个配置和测试代码。
Spring 3.2 @Autowired异常:expected single matching bean but found 2的更多相关文章
- 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 ...
- 深入Spring Boot:怎样排查expected single matching bean but found 2的异常
写在前面 这个demo来说明怎么排查一个常见的spring expected single matching bean but found 2的异常. https://github.com/hengy ...
- spring依赖注入单元测试:expected single matching bean but found 2
异常信息:org.springframework.beans.factory.UnsatisfiedDependencyException: Caused by: org.springframewor ...
- spring " expected single matching bean but found 2" 问题一例。
初入java,使用spring时遇到一个问题,左边是一个接口和实现.右边是service和实现. @Service@Transactional(rollbackFor = Exception.clas ...
- 多个@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 ' ...
- expected single matching bean but found 2
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'acc ...
- 多数据源报错 expected single matching bean but found 2: xxx,xxx
问题: expected single matching bean but found 2: xxx,xxx 原因:在 Spring 容器中配置了两个类型Bean,Spring 容器将无法确定到底要用 ...
- 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< ...
- expected single matching bean but found 2: menusServiceImpl,IMenusService
问题如下: 接口也作为匹配的bean? 有点迷惑了....... 经过在网上找资料,发现和@MapperScan这个注解有关系,具体源码不止.但是这个注解会扫描路径下的所有类. 去掉这个注解就可以正常 ...
随机推荐
- ABP ModuleZero 添加角色_创建角色是报错的问题解决方案
ABP升级后,大概3.6.1以后,在.net framework里面,从官方下载的Module zero模板添加角色是出现下面错误. 这个问题,算是新版apb的一点小缺憾,好像在.net core的模 ...
- pxe前期接入H3C交换机网络准备
环境:一个装机vlan3010,一个业务vlan,将接入交换机的下联,上联设置好vlan 如果服务器一直出于dhcp状态,有可能是交换机到服务器的光纤线路有问题,建议在交换机查看端口是否是down的. ...
- beta阶段博客合集
第一次博客 第二次博客 第三次博客 第四次博客 第五次博客
- 【第二周】PSP
日期 C类别 C内容 S开始时间 E结束时间 I间隔(单位:分钟) T净时间(单位:分钟) 9月8日 编程 结对编程 12:15 13:15 10 50 编程 结对编程 16:35 17:30 ...
- Selenium WebDriver 中鼠标和键盘事件分析及扩展(转)
文章转自:http://www.ibm.com/developerworks/cn/java/j-lo-keyboard/
- mac下面安装redis
本文只记录了在homebrew下面安装redis的过程,过程比较简单,作为自己以后翻阅用吧, 首先安装homebrew,打开终端,在终端下面允许下面的命令(不要用root用户): /usr/bin/r ...
- [转帖].net 4.8 将不再支持win7 win8 版本
ZT:https://blogs.msdn.microsoft.com/dotnet/2018/07/18/announcing-net-framework-4-8-early-access-buil ...
- 函数调用时形参的传递也会被认为是赋值操作(继承自Object后会出现的问题)
http://blog.csdn.net/houqd2012/article/details/25070987
- Node初识笔记 1第一周
#下载安装好node > https://nodejs.org/en/ # 打开cmd 调整好执行路径 . 1.js是JS文件名,cd调招路径,‘node’+空格 +JS文件名(带上扩展名) ...
- SD/MMC相关寄存器的介绍
1.SD卡内部架构 在熟悉SD/MMC相关寄存器之前,我们先来看看SD卡的内部架构是怎么样的,如下图所示: 2.SD/MMC相关寄存器的介绍 从上图中总结出:SD卡内部有7个寄存器. 一.OCR,CI ...