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这个注解有关系,具体源码不止.但是这个注解会扫描路径下的所有类. 去掉这个注解就可以正常 ...
随机推荐
- 【emWin】例程五:显示数值
实验指导书及代码包下载: 链接:http://pan.baidu.com/s/1pLexsAf密码:p0jf 实验现象:
- hihoCoder 1393 网络流三·二分图多重匹配(Dinic求二分图最大多重匹配)
#1393 : 网络流三·二分图多重匹配 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 学校的秋季运动会即将开始,为了决定参赛人员,各个班又开始忙碌起来. 小Hi和小H ...
- select 选择的制作
我说的select选择是指 手机端的话,一般考虑元素 + 伪类制作 .checkbox{ border:1px solid #987;width:16px;height:16px; } .checkb ...
- asp.net core项目发布网站时的选项
发布网站时的选项 Debug 通常称为调试版本,它包含调试信息,并且不作任何优化,便于程序员调试程序. Release 称为发布版本,它往往是进行了各种优化,使得程序在代码大小和运行速度上都是最优的, ...
- VirtualBox Ubuntu Server 16.04 手动设置 网络(IP, DNS, 路由)
1. VirtualBox 设置全局网络 在virtualBox点击菜单管理->全局管理 配置NAT网络 参考下图配置, 依次点击相应的按钮并设置网络(其中DHCP任意, 将来我们都会使用固定I ...
- Ruby-随机数
--随机0-1 rand --随机一个范围 rand(1..100)
- 总结-Hibernate
JPA 全称 Java Persistence API @Entity @Table(name = "user") public class User { @Id @Generat ...
- mysql大表myisam的导入
在my.cnf中增大以下参数 myisam_sort_buffer_size = 1024Mtmp_table_size = 256M tmpdir = /home/tmpmyisam_max_sor ...
- Xamarin.Android 应用程序配置
* 在 Xamarin 中 Android 清单文件的内容一般不通过手动编辑,而是由编译器根据 项目属性设置 和 一系列 特性类 自动生成 1. 应用程序在android启动器中显示的名称设置: 主活 ...
- 利用jQuery对插件进行扩展时,方法$.extend()、$.fn.extend()区别与联系
利用JQ开发插件的方法: 1.jQuery.extend(); 2.jQuery.fn.extend(); 3.通过$.widget()应用jQuery UI的部件工厂方式创建. 由于第三种方式通 ...