在配置sharding-jdbc中

    spring.shardingsphere.datasource.names=ds0,ds1

spring.shardingsphere.datasource.ds0.type=com.zaxxer.hikari.HikariDataSource
spring.shardingsphere.datasource.ds0.driverClassName=com.mysql.jdbc.Driver
spring.shardingsphere.datasource.ds0.jdbcUrl=xxx
spring.shardingsphere.datasource.ds0.username=root
spring.shardingsphere.datasource.ds0.password=xxxx

spring.shardingsphere.datasource.ds1.type=com.alibaba.druid.pool.DruidDataSource
spring.shardingsphere.datasource.ds1.driverClassName=com.mysql.jdbc.Driver
spring.shardingsphere.datasource.ds1.url=xxx
spring.shardingsphere.datasource.ds1.username=root
spring.shardingsphere.datasource.ds1.password=xxxx



spring.shardingsphere.sharding.tables.t_order.actual-data-nodes=ds$->{0..1}.t_order_$->{1..2}
spring.shardingsphere.sharding.default-database-strategy.inline.sharding-column=user_id
spring.shardingsphere.sharding.default-database-strategy.inline.algorithm-expression=ds$->{user_id % 2}
spring.shardingsphere.sharding.tables.t_order.table-strategy.inline.sharding-column=id
spring.shardingsphere.sharding.tables.t_order.table-strategy.inline.algorithm-expression=t_order_$->{id % 2 +1}






mybatis-plus.mapper-locations=classpath*:/mapper/*.xml

出现了Consider the following: If you want an embedded database (H2, HSQL or Derby), please put it on the

		<dependency>
		        <groupId>com.baomidou</groupId>
		        <artifactId>mybatis-plus-boot-starter</artifactId>
		        <version>3.4.0</version>
		    </dependency>
<!--        <dependency>-->
<!--            <groupId>com.alibaba</groupId>-->
<!--            <artifactId>druid-spring-boot-starter</artifactId>-->
<!--              <version>1.2.8</version>-->
<!--        </dependency>-->

将上面的依赖修改为

 <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>3.4.0</version>
        </dependency>

        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid</artifactId>
            <version>1.2.8</version>
        </dependency>

或者换成同一hikari数据源/或者druid数据源

更多推荐

Consider the following: If you want an embedded database (H2, HSQL or Derby), pl