springboot整合shardingsphere的允许bean的覆盖

Caused by: org.springframework.beans.factory.support.BeanDefinitionOverrideException: Invalid bean definition with name 'dataSource' defined in class path resource [org/apache/shardingsphere/shardingjdbc/spring/boot/SpringBootConfiguration.class]: Cannot register bean definition [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; 
dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.apache.shardingsphere.shardingjdbc.spring.boot.SpringBootConfiguration; 

factoryMethodName=dataSource; initMethodName=null; destroyMethodName=(inferred); defined in class path resource 
[org/apache/shardingsphere/shardingjdbc/spring/boot/SpringBootConfiguration.class]] for bean 'dataSource': There is already [Root bean: class [null]; 
scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; 
autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration$Hikari; 
factoryMethodName=dataSource; initMethodName=null; destroyMethodName=(inferred); 
defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]] bound.

在配置文件使用bean的覆盖配置:

spring.main.allow-bean-definition-overriding=true

版权声明:本文为m0_59662444原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。