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

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

时间: 2024-07-30 18:05:16

springboot多数据源启动报错:required a single bean, but 6 were found:的相关文章

spring cloud gateway网关启动报错:No qualifying bean of type 'org.springframework.web.reactive.DispatcherHandler'

网关配置好后启动报错如下: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is java.lang.RuntimeException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'servletEndpoint

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

Spring Boot发布war包流程: 1.修改web model的pom.xml <packaging>war</packaging> SpringBoot默认发布的都是jar,因此要修改默认的打包方式jar为war 2.修改web model的依赖(dependency) <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boo

springboot启动报错:Failed to configure a DataSource

一.背景 springboot的出现,让项目搭建变得更方便快捷,同时简化掉很多的样板化配置代码,提高开发效率. 通过idea生成springboot项目,启动报错:Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured. 通过错误不难看出是因为dataSource的url配置缺失导致,但是新生成的项目并没有使用到jdbc,为什

springboot启动报错:&quot;Error starting ApplicationContext. To display the conditions report re-run your application with &#39;debug&#39; enabled.&quot;

报错内容 java.lang.Object.wait(Native Method)java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:143)com.mysql.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:41)2019-02-14 14:58:00.326 INFO 17688 --- [ main] Condition

第一个springboot项目启动报错Failed to configure a DataSource: &#39;url&#39; attribute is not specified and no embedded datasource could be configured.

报错内容具体如下 *************************** APPLICATION FAILED TO START *************************** Description: Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured. Reason: Failed to determine a

eclipse 启动报错has value &#39;1.7&#39;, but &#39;1.8&#39; is required

由于安装elasticsearch5.x版本时需要jdk8,所以在本机安装了,不过后来发现启动eclipse时报错: Error: Registry key 'Software\JavaSoft\Java RuntimeEnvironment'\CurrentVersion' has value '1.7', but '1.8' is required. 根据提示修改了注册表中的CurrentVersion值为1.7 但是修改后依然报错,怎么回事呢?于是在网上找资料最后发现修改如下配置即可: 将

springboot启动报错退出,To display the conditions report re-run your application with &#39;debug&#39; enabled.

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.2019-01-19 12:01:39.870 ERROR 8324 --- [  restartedMain] o.s.b.d.LoggingFailureAnalysisReporter   : ***************************APPLICATIO

springboot启动报错start bean &#39;eurekaAutoServiceRegistration&#39; NullPointerException

解决方案参考:https://blog.csdn.net/hhj13978064496/article/details/82825365 我将eureka的依赖包放到了依赖包的最下面,启动报错, 如下: <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId&

springboot项目启动报错 url&#39; attribute is not specified and no embedded datasource could be configured

报错相关信息: 2019-07-22 17:12:48.971 ERROR 8312 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPLICATION FAILED TO START *************************** Description: Failed to configure a DataSource: 'url' attribute is not