开发者社区 问答 正文

spring配置多数据源t junit测试报错 <b> ?报错

Error creating bean with name 'seentao.workflow.engine.EngineTest': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests.setDataSource(javax.sql.DataSource); nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [javax.sql.DataSource] is defined: expected single matching bean but found 3: [mysql, mysqlTo, dynamicDatasource]

报错信息的意识是,spring配置了[mysql, mysqlTo, dynamicDatasource]3个数据源,测试时不知道使用哪一个,请教如何配置junit才能不报错。

展开
收起
爱吃鱼的程序员 2020-06-23 01:19:32 627 分享 版权
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    注解时byName不要byType

    2020-06-23 01:19:48
    赞同 展开评论