以springboot 来开始使用shardingjdbc
- 引入shardingjdbc starter依赖
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-jdbc-core-spring-boot-starter</artifactId>
<version>${shardingsphere.version}</version>
</dependency>
其他的比如数据库连接驱动,mybaytis,等引入,完整pom如下
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>shardingjdbcDemo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>shardingjdbcDemo</name>
<description>Demo project for shardingJdbc</description>
<properties>
<java.version>1.8</java.version>
<shardingsphere.version>5.0.0</shardingsphere.version>
<hikaricp.version>3.4.5</hikaricp.version>
<mybatisplus-version>3.4.3.1</mybatisplus-version>
<mysql-connector-version>8.0.27</mysql-connector-version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>