apache / shardingsphere

Distributed SQL transaction & query engine for data sharding, scaling, encryption, and more - on any database.
Apache License 2.0
19.8k stars 6.7k forks source link

SpringBoot 2.1.1.RELEASE 自动配置数据源与Sharding自动配置冲突 #2588

Closed weweibuy closed 5 years ago

weweibuy commented 5 years ago

SpringBoot版本2.1.1.RELEASE; sharding-jdbc-spring-boot-starter 版本4.0.0-RC1; spring: shardingsphere: enabled: true datasource: names: ds0,ds1 ds0: type: com.alibaba.druid.pool.DruidDataSource driver-class-name: org.gjt.mm.mysql.Driver url: jdbc:mysql://localhost:3306/webuy_learning_0?useUnicode=true&characterEncoding=UTF-8 username: user01 password: user01 ds1: type: com.alibaba.druid.pool.DruidDataSource driver-class-name: org.gjt.mm.mysql.Driver url: jdbc:mysql://localhost:3306/webuy_learning_1?useUnicode=true&characterEncoding=UTF-8 username: user01 password: user01 sharding: default-data-source-name: ds tables: jit_time_order_header: actual-data-nodes: ds$->{0..1}.jit_time_orderheader$->{0..1} database-strategy: inline: shardingColumn: time_order_no algorithm-expression: ds$->{Math.abs(time_order_no.hashCode()) % 2} table-strategy: inline: sharding-column: time_order_no algorithm-expression: jit_time_orderheader$->{Math.abs(com.weweibuy.webuy.learning.sharing.utils.HashUtil.FNVHash1(time_order_no)) % 2}

项目启动报错: The bean 'dataSource', defined in class path resource [org/apache/shardingsphere/shardingjdbc/spring/boot/SpringBootConfiguration.class], could not be registered. A bean with that name has already been defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class] and overriding is disabled.

terrymanu commented 5 years ago

For English only, other languages will not accept.

syanfox commented 5 years ago

Has it been solved? @weweibuy