Overview

ShardingSphere provides a JDBC driver, and developers can configure ShardingSphereDriver in Spring Boot to use ShardingSphere.

Usage

Import Maven Dependency

  1. <dependency>
  2. <groupId>org.apache.shardingsphere</groupId>
  3. <artifactId>shardingsphere-jdbc-core</artifactId>
  4. <version>${shardingsphere.version}</version>
  5. </dependency>

Configure Spring Boot Properties

  1. # Configuring DataSource Drivers
  2. spring.datasource.driver-class-name=org.apache.shardingsphere.driver.ShardingSphereDriver
  3. # Specify a YAML configuration file
  4. spring.datasource.url=jdbc:shardingsphere:classpath:xxx.yaml

Use Data Source

Use this data source directly; or configure ShardingSphereDataSource to be used in conjunction with ORM frameworks such as JPA, Hibernate, and MyBatis.