1) 启动springboot 项目,出现java.sql.SQLException: The url cannot be null
因为我之前是用的单库,直接用的druid 方式,改为分库结构的时候,把原来的druid 删除掉了,只引用了sharding,所以出现上诉错误;调整为:
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.16</version>
</dependency>
<!--shardingsphere的springboot依赖jar-->
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>sharding-jdbc-spring-boot-starter</artifactId>
<version>4.0.0-RC1</version>
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>sharding-jdbc-spring-namespace</artifactId>
<version>4.0.0-RC1</version>
</dependency>
2)修改了引用包后,启动又出现 Data sources cannot be empty
原来我配置文件写的是sharding.jdbc.datasource 这样格式的,还是沿用3.1版本的
最后修改为 spring.shardingsphere.datasource 这样格式就可以了,下面为部分截图