spring " expected single matching bean but found 2" 问题一例。
初入java,使用spring时遇到一个问题,左边是一个接口和实现。右边是service和实现。

@Service
@Transactional(rollbackFor = Exception.class)
public class DefaultSerializeSettingManage implements SerializeSettingService { @Autowired
SerializeSettingDAO settingdao; //部署项目时,此行代码引发异常:&*%&(()()&*&&^%^$%$&&*&* expected single matching bean but found 2:defaultSettingDAO,serializeSettingDAO
} 当时,很疑惑,每个接口都只有一个实现,为什么会提示:but found 2:defaultSettingDAO,serializeSettingDAO
而且提示的这两个名称的首字母都是小写呢? 从网上查这个资料:http://stackoverflow.com/questions/8414287/spring-autowiring-with-unique-beans-spring-expected-single-matching-bean-but-fo 下面这个答案虽然不是正确答案,但是 提供了一个线索。 我把变量定义改成:
@Autowired
SerializeSettingDAO serializeSettingDAO; 就好了。

虽然是java新手,但是对java这种约束实在很想吐槽。呵呵
期待高手给出正解!
ps:这个答案似乎解释了些东西:

spring " expected single matching bean but found 2" 问题一例。的更多相关文章
- 深入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 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 3.2 @Autowired异常:expected single matching bean but found 2
在使用Sping做单元测试时候,对RequestMappingHandlerAdapter(从处理器包装过来的适配器)进行自动装配, 发现报:expected single matching bean ...
- 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 容器将无法确定到底要用 ...
- 多个@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 ' ...
- 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这个注解有关系,具体源码不止.但是这个注解会扫描路径下的所有类. 去掉这个注解就可以正常 ...
随机推荐
- MySQL数据的主从复制、半同步复制和主主复制详解
一.MySQL复制概述 ⑴.MySQL数据的复制的基本介绍 目前MySQL数据库已经占去数据库市场上很大的份额,其一是由于MySQL数据的开源性和高性能,当然还有重要的一条就是免费~不过不知道还能免费 ...
- Codeforces Good Bye 2016 D 模拟搜索?
给出烟花的爆炸方式和爆炸次数 问最后有多少个格子会被炸到 如果dfs的话会超时... 利用模拟每一层来搜索..? 思想就是一开始有一个爆炸点向上 然后模拟完第一段 会产生一个爆炸点 朝两个方向 就用v ...
- MyEclipse 点击 部署 按钮 无效
找到MyEclipse的工作路径,我的是"D:\Workspace",到这个目录中去"\.metadata\.plugins\org.eclipse.core.runti ...
- 访问API安全性认证设计
1.用户POST登录(账号+密码) | |成功 |2.返回(Private key+时间戳)加密字符串+用户信息+缓存到内存中 | |发起其它请求 |3.发起请求时携带Request参数和(Reque ...
- Universal Link 笔记
如何实现Universal Link? 简单地说三步,1.把一个配置文件放在指定服务器根目录 2.在Xcode中设置AssociateDomain 3.安装app时,会根据Xcode中设置的Assoc ...
- JAVA修饰符
修饰符用来定义类.方法或者变量,通常放在语句的最前端.我们通过下面的例子来说明: public class className { // ... } private boolean myFlag; s ...
- 如何添加Tomcat为启动服务
tomcat8.0, 可以用startup.bat启动, 但注销又不能启动服务,但现在的系统不知出了什么问题 ? 答 1.我这个是zip版本的,所以里面有一个service.bat的文件,所以很简单 ...
- RabbitMQ学习总结 第七篇:RCP(远程过程调用协议)
在http://www.cnblogs.com/leocook/p/mq_rabbitmq_2.html 这篇博文中我们实现了怎么去使用work queue来把比较耗时的任务分散给多个worker. ...
- Ionic- Android 开发环境搭建
Ionic- Android 开发环境搭建 为时一周的IONIC ADNROID 环境终于在各种处理错误中搭建成功,以下记录下搭建过程中遇到的各种情况的处理办法. 一 首先,当然是enviroment ...
- 通过代码自定义cell(cell的高度不一致)