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

Posted Time。时光

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了springboot多数据源启动报错:required a single bean, but 6 were found:相关的知识,希望对你有一定的参考价值。

技术群: 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:的主要内容,如果未能解决你的问题,请参考以下文章

008-SpringBoot发布WAR启动报错:Error assembling WAR: webxml attribute is required

springboot启动提示连接mysql报错:java.sql.SQLNonTransientConnectionException: CLIENT_PLUGIN_AUTH is required(

spring boot 2.0 报错:“jdbcUrl is required with driverClassName.” 解决办法!

springboot 报错Field XXX required a bean of type XXX that could not be found.

SpringBoot项目启动出现required a bean of type 'XXX' that could not be found

idea springboot 多模块项目,将某个模块的内容迁移到其他模块,然后删除该模块,项目启动报错