Spring的JUnit错误:NoSuchBeanDefinitionException: No unique bean of type,expected single matching bean but found 2 [dataSource1,data
来源:互联网 发布:4g网络测试 编辑:程序博客网 时间:2024/05/29 14:51
当配置文件中有两个spring datasource时,利用Spring的JUnit测试会报如下错误:
NoSuchBeanDefinitionException: No unique bean of type,expected single matching bean but found 2 [dataSource1,dataSource2]
测试类的annotation如下:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"/applicationContext-resources.xml"})
@TransactionConfiguration(transactionManager = "txManager", defaultRollback = true)
@Transactional
public class MyTest extends AbstractTransactionalJUnit4SpringContextTests {
......
}
原因是:不知道注入哪个数据源,改成一个数据源即可
<alias name='dataSource' alias='dataSource1'/>
<alias name='dataSource' alias='dataSource2'/>
- Spring的JUnit错误:NoSuchBeanDefinitionException: No unique bean of type,expected single matching bean but found 2 [dataSource1,data
- No qualifying bean of type is defined: expected single matching bean but found 2
- spring注解错误-expected single matching bean but found 2
- No unique bean of type is defined: expected single bean but found 0
- expected single matching bean but found 2
- expected single matching bean but found 2
- expected single matching bean but found 2
- expected single matching bean but found 2
- 深入Spring Boot:怎样排查expected single matching bean but found 2的异常
- Injection expected single matching bean but found
- No unique bean of type [com.yuanv.backstage.dao.SysUserDao] is defined: expected single matching bea
- expected single matching bean but found 2 注解继承冲突
- 多数据源报错 expected single matching bean but found 2
- Spring JavaConfig - NoSuchBeanDefinitionException: No unique bean of type
- spring依赖注入单元测试:expected single matching bean but found 2
- spring依赖注入单元测试:expected single matching bean but found 2
- spring依赖注入单元测试:expected single matching bean but found 2
- spring boot+mybatis 多数据源报错 expected single matching bean but found
- 【转】【C/C++语言入门篇】 调试基础
- 好强的英语句法(看了这些想不过四六级都难~~~)
- 【转】【C/C++语言入门篇】-- 基本数据类型
- 复制SQL Server数据库
- 【转】【C/C++语言入门篇】-- HelloWorld思考
- Spring的JUnit错误:NoSuchBeanDefinitionException: No unique bean of type,expected single matching bean but found 2 [dataSource1,data
- 防火墙 Hillstone Networks SA-2003
- 【转】【C/C++语言入门篇】--序言
- 从SPView中取得ViewFields不正确
- 【转】C/C++条件(三目)运算符巧妙原理解析
- 使用LoadRunner进行资源占用率进行分析
- document.getElementsById("nameid").className="gaodu";不执行
- 采访Gavin King(待续)
- 简单的拍卖博弈