There are two ways you can configure Apache ShardingSphere: Java
and YAML
.
Developers can choose the preferred method according to their requirements.
Currently only Java language is supported.
The development environment requires Java JRE 8 or later.
Please refer to User Manual for more details.
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-jdbc-core</artifactId>
<version>${latest.release.version}</version>
</dependency>
Notice: Please change
${latest.release.version}
to the actual version.
# JDBC database name. In cluster mode, use this parameter to connect ShardingSphere-JDBC and ShardingSphere-Proxy.
# Default:logic_db
databaseName (?):
mode:
dataSources:
rules:
- !FOO_XXX
...
- !BAR_XXX
...
props:
key_1: value_1
key_2: value_2
spring boot
as an example, edit application.properties
.# Configuring DataSource Drivers
spring.datasource.driver-class-name=org.apache.shardingsphere.driver.ShardingSphereDriver
# Specify a YAML configuration file
spring.datasource.url=jdbc:shardingsphere:classpath:xxx.yaml
For details, see Spring Boot.