码迷,mamicode.com
首页 > 编程语言 > 详细

springboot多数据源启动报错:required a single bean, but 6 were found:

时间:2020-01-16 16:07:03      阅读:158      评论:0      收藏:0      [点我收藏+]

标签:href   cti   isa   figure   toc   数据   ons   image   conf   

技术群: 816227112

参考:https://stackoverflow.com/questions/43455869/could-not-autowire-there-is-more-than-one-bean-of-datasource-type

Parameter 0 of method redisTemplate in org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration required a single bean, but 6 were found:
    - agencyConnectionFactory: defined by method ‘agencyConnectionFactory‘ in class path resource [com/sinosoft/config/RedisConfig.class]
    - cellConnectionFactory: defined by method ‘cellConnectionFactory‘ in class path resource [com/sinosoft/config/RedisConfig.class]
    - mipConnectionFactory: defined by method ‘mipConnectionFactory‘ in class path resource [com/sinosoft/config/RedisConfig.class]
    - wechatConnectionFactory: defined by method ‘wechatConnectionFactory‘ in class path resource [com/sinosoft/config/RedisConfig.class]
    - ybtbConnectionFactory: defined by method ‘ybtbConnectionFactory‘ in class path resource [com/sinosoft/config/RedisConfig.class]
    - ybtgConnectionFactory: defined by method ‘ybtgConnectionFactory‘ in class path resource [com/sinosoft/config/RedisConfig.class]

除了这种还有配置数据库多数据源也会出现这种情况。

解决:

报错的某一个配置上加上@Primary

技术图片

springboot多数据源启动报错:required a single bean, but 6 were found:

标签:href   cti   isa   figure   toc   数据   ons   image   conf   

原文地址:https://www.cnblogs.com/helloworld6379/p/12201704.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!