This is an automated email from the ASF dual-hosted git repository.
kimmking pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 394e8c7 Add spring-boot-starter index (#6106)
394e8c7 is described below
commit 394e8c798a1a8a645bfb513e26e148c7bb32fe7b
Author: Liang Zhang <[email protected]>
AuthorDate: Thu Jun 18 00:21:30 2020 +0800
Add spring-boot-starter index (#6106)
* Add spring-boot-starter folder
* Add spring-boot-starter index
---
.../configuration/config-spring-namespace.cn.md | 727 --------------------
.../configuration/config-spring-namespace.en.md | 753 ---------------------
.../configuration/spring-boot-starter/_index.cn.md | 74 ++
.../configuration/spring-boot-starter/_index.en.md | 74 ++
.../config-spring-boot.cn.md | 0
.../config-spring-boot.en.md | 0
.../configuration/yaml/_index.cn.md | 6 +-
.../configuration/yaml/_index.en.md | 2 +-
.../configuration/yaml/config-yaml.cn.md | 4 +-
.../configuration/yaml/config-yaml.en.md | 10 +-
10 files changed, 159 insertions(+), 1491 deletions(-)
diff --git
a/docs/document/content/user-manual/shardingsphere-jdbc/configuration/config-spring-namespace.cn.md
b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/config-spring-namespace.cn.md
deleted file mode 100644
index 6278c3a..0000000
---
a/docs/document/content/user-manual/shardingsphere-jdbc/configuration/config-spring-namespace.cn.md
+++ /dev/null
@@ -1,727 +0,0 @@
-+++
-title = "Spring命名空间配置"
-weight = 4
-+++
-
-## 注意事项
-
-行表达式标识符可以使用`${...}`或`$->{...}`,但前者与Spring本身的属性文件占位符冲突,因此在Spring环境中使用行表达式标识符建议使用`$->{...}`。
-
-## 配置示例
-example:
[shardingsphere-example](https://github.com/apache/shardingsphere/tree/master/examples/shardingsphere-jdbc-example/sharding-example/sharding-spring-namespace-jpa-example)
-### 数据分片
-
-```xml
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:p="http://www.springframework.org/schema/p"
- xmlns:context="http://www.springframework.org/schema/context"
- xmlns:tx="http://www.springframework.org/schema/tx"
-
xmlns:sharding="http://shardingsphere.apache.org/schema/shardingsphere/sharding"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
-
http://www.springframework.org/schema/beans/spring-beans.xsd
-
http://shardingsphere.apache.org/schema/shardingsphere/sharding
-
http://shardingsphere.apache.org/schema/shardingsphere/sharding/sharding.xsd
- http://www.springframework.org/schema/context
-
http://www.springframework.org/schema/context/spring-context.xsd
- http://www.springframework.org/schema/tx
-
http://www.springframework.org/schema/tx/spring-tx.xsd">
- <context:annotation-config />
-
- <bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
- <property name="dataSource" ref="shardingDataSource" />
- <property name="jpaVendorAdapter">
- <bean
class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"
p:database="MYSQL" />
- </property>
- <property name="packagesToScan"
value="org.apache.shardingsphere.example.core.jpa.entity" />
- <property name="jpaProperties">
- <properties>
- <prop
key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
- <prop key="hibernate.hbm2ddl.auto">create</prop>
- <prop key="hibernate.show_sql">true</prop>
- </properties>
- </property>
- </bean>
- <bean id="transactionManager"
class="org.springframework.orm.jpa.JpaTransactionManager"
p:entityManagerFactory-ref="entityManagerFactory" />
- <tx:annotation-driven />
-
- <bean id="ds0" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
- <property name="driverClassName" value="com.mysql.jdbc.Driver" />
- <property name="url" value="jdbc:mysql://localhost:3306/ds0" />
- <property name="username" value="root" />
- <property name="password" value="" />
- </bean>
-
- <bean id="ds1" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
- <property name="driverClassName" value="com.mysql.jdbc.Driver" />
- <property name="url" value="jdbc:mysql://localhost:3306/ds1" />
- <property name="username" value="root" />
- <property name="password" value="" />
- </bean>
-
- <bean id="preciseModuloDatabaseShardingAlgorithm"
class="org.apache.shardingsphere.example.algorithm.PreciseModuloShardingDatabaseAlgorithm"
/>
- <bean id="preciseModuloTableShardingAlgorithm"
class="org.apache.shardingsphere.example.algorithm.PreciseModuloShardingTableAlgorithm"
/>
-
- <sharding:standard-strategy id="databaseShardingStrategy"
sharding-column="user_id"
precise-algorithm-ref="preciseModuloDatabaseShardingAlgorithm" />
- <sharding:standard-strategy id="tableShardingStrategy"
sharding-column="order_id"
precise-algorithm-ref="preciseModuloTableShardingAlgorithm" />
-
- <sharding:key-generate-strategy id="orderKeyGenerator" type="SNOWFLAKE"
column="order_id" />
- <sharding:key-generate-strategy id="itemKeyGenerator" type="SNOWFLAKE"
column="order_item_id" />
-
- <sharding:data-source id="shardingDataSource">
- <sharding:sharding-rule data-source-names="ds0,ds1">
- <sharding:table-rules>
- <sharding:table-rule logic-table="t_order"
actual-data-nodes="ds$->{0..1}.t_order$->{0..1}"
database-strategy-ref="databaseShardingStrategy"
table-strategy-ref="tableShardingStrategy"
key-generate-strategy-ref="orderKeyGenerator" />
- <sharding:table-rule logic-table="t_order_item"
actual-data-nodes="ds$->{0..1}.t_order_item$->{0..1}"
database-strategy-ref="databaseShardingStrategy"
table-strategy-ref="tableShardingStrategy"
key-generate-strategy-ref="itemKeyGenerator" />
- </sharding:table-rules>
- <sharding:binding-table-rules>
- <sharding:binding-table-rule logic-tables="t_order,
t_order_item" />
- </sharding:binding-table-rules>
- <sharding:broadcast-table-rules>
- <sharding:broadcast-table-rule table="t_config" />
- </sharding:broadcast-table-rules>
- </sharding:sharding-rule>
- </sharding:data-source>
-</beans>
-```
-
-### 读写分离
-
-```xml
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:context="http://www.springframework.org/schema/context"
- xmlns:p="http://www.springframework.org/schema/p"
- xmlns:tx="http://www.springframework.org/schema/tx"
-
xmlns:master-slave="http://shardingsphere.apache.org/schema/shardingsphere/masterslave"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
-
http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/context
-
http://www.springframework.org/schema/context/spring-context.xsd
- http://www.springframework.org/schema/tx
- http://www.springframework.org/schema/tx/spring-tx.xsd
-
http://shardingsphere.apache.org/schema/shardingsphere/masterslave
-
http://shardingsphere.apache.org/schema/shardingsphere/masterslave/master-slave.xsd">
- <context:annotation-config />
- <context:component-scan
base-package="org.apache.shardingsphere.example.core.jpa" />
-
- <bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
- <property name="dataSource" ref="masterSlaveDataSource" />
- <property name="jpaVendorAdapter">
- <bean
class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"
p:database="MYSQL" />
- </property>
- <property name="packagesToScan"
value="org.apache.shardingsphere.example.core.jpa.entity" />
- <property name="jpaProperties">
- <properties>
- <prop
key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
- <prop key="hibernate.hbm2ddl.auto">create</prop>
- <prop key="hibernate.show_sql">true</prop>
- </properties>
- </property>
- </bean>
- <bean id="transactionManager"
class="org.springframework.orm.jpa.JpaTransactionManager"
p:entityManagerFactory-ref="entityManagerFactory" />
- <tx:annotation-driven />
-
- <bean id="ds_master" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
- <property name="driverClassName" value="com.mysql.jdbc.Driver" />
- <property name="url" value="jdbc:mysql://localhost:3306/ds_master" />
- <property name="username" value="root" />
- <property name="password" value="" />
- </bean>
-
- <bean id="ds_slave0" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
- <property name="driverClassName" value="com.mysql.jdbc.Driver" />
- <property name="url" value="jdbc:mysql://localhost:3306/ds_slave0" />
- <property name="username" value="root" />
- <property name="password" value="" />
- </bean>
-
- <bean id="ds_slave1" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
- <property name="driverClassName" value="com.mysql.jdbc.Driver" />
- <property name="url" value="jdbc:mysql://localhost:3306/ds_slave1" />
- <property name="username" value="root" />
- <property name="password" value="" />
- </bean>
-
- <!-- 4.0.0-RC1 版本 负载均衡策略配置方式 -->
- <!-- <bean id="randomStrategy"
class="org.apache.shardingsphere.example.spring.namespace.algorithm.masterslave.RandomMasterSlaveLoadBalanceAlgorithm"
/> -->
-
- <!-- 4.0.0-RC2 之后版本 负载均衡策略配置方式 -->
- <master-slave:load-balance-algorithm id="randomStrategy" type="RANDOM" />
-
- <master-slave:data-source id="masterSlaveDataSource"
master-data-source-name="ds_master" slave-data-source-names="ds_slave0,
ds_slave1" strategy-ref="randomStrategy">
- <master-slave:properties>
- <prop key="sql.show">true</prop>
- <prop key="executor.size">10</prop>
- <prop key="foo">bar</prop>
- </master-slave:properties>
- </master-slave:data-source>
-</beans>
-```
-
-### 数据加密
-
-```xml
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-
xmlns:encrypt="http://shardingsphere.apache.org/schema/shardingsphere/encrypt"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
-
http://www.springframework.org/schema/beans/spring-beans.xsd
-
http://shardingsphere.apache.org/schema/shardingsphere/encrypt
-
http://shardingsphere.apache.org/schema/shardingsphere/encrypt/encrypt.xsd
- ">
-
- <bean id="ds" class="com.zaxxer.hikari.HikariDataSource"
destroy-method="close">
- <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
- <property name="jdbcUrl"
value="jdbc:mysql://localhost:3306/demo_ds?useSSL=false&useUnicode=true&characterEncoding=UTF-8"/>
- <property name="username" value="root"/>
- <property name="password" value=""/>
- </bean>
-
- <encrypt:encrypt-algorithm id="aes_encryptor" type="AES">
- <properties>
- <prop key="aes.key.value">123456</prop>
- </properties>
- </encrypt:encrypt-algorithm>
- <encrypt:encrypt-algorithm id="md5_encryptor" type="MD5" />
-
- <encrypt:data-source id="encryptDataSource" data-source-name="ds" >
- <encrypt:encrypt-rule>
- <encrypt:tables>
- <encrypt:table name="t_order">
- <encrypt:column logic-column="user_id"
cipher-column="user_encrypt" assisted-query-column="user_assisted"
plain-column="user_decrypt" encrypt-algorithm-ref="aes_encryptor" />
- <encrypt:column logic-column="order_id"
cipher-column="order_encrypt" assisted-query-column="order_assisted"
plain-column="order_decrypt" encrypt-algorithm-ref="md5_encryptor" />
- </encrypt:table>
- </encrypt:tables>
- </encrypt:encrypt-rule>
- <encrypt:properties>
- <prop key="sql.show">true</prop>
- <prop key="query.with.cipher.column">true</prop>
- </encrypt:properties>
- </encrypt:data-source>
-</beans>
-```
-
-### 数据分片 + 读写分离
-
-```xml
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:p="http://www.springframework.org/schema/p"
- xmlns:context="http://www.springframework.org/schema/context"
- xmlns:tx="http://www.springframework.org/schema/tx"
-
xmlns:sharding="http://shardingsphere.apache.org/schema/shardingsphere/sharding"
-
xmlns:master-slave="http://shardingsphere.apache.org/schema/shardingsphere/masterslave"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
-
http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/context
-
http://www.springframework.org/schema/context/spring-context.xsd
- http://www.springframework.org/schema/tx
- http://www.springframework.org/schema/tx/spring-tx.xsd
-
http://shardingsphere.apache.org/schema/shardingsphere/sharding
-
http://shardingsphere.apache.org/schema/shardingsphere/sharding/sharding.xsd
-
http://shardingsphere.apache.org/schema/shardingsphere/masterslave
-
http://shardingsphere.apache.org/schema/shardingsphere/masterslave/master-slave.xsd">
- <context:annotation-config />
- <context:component-scan
base-package="org.apache.shardingsphere.example.core.jpa" />
-
- <bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
- <property name="dataSource" ref="shardingDataSource" />
- <property name="jpaVendorAdapter">
- <bean
class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"
p:database="MYSQL" />
- </property>
- <property name="packagesToScan"
value="org.apache.shardingsphere.example.core.jpa.entity" />
- <property name="jpaProperties">
- <properties>
- <prop
key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
- <prop key="hibernate.hbm2ddl.auto">create</prop>
- <prop key="hibernate.show_sql">true</prop>
- </properties>
- </property>
- </bean>
- <bean id="transactionManager"
class="org.springframework.orm.jpa.JpaTransactionManager"
p:entityManagerFactory-ref="entityManagerFactory" />
- <tx:annotation-driven />
-
- <bean id="ds_master0" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
- <property name="driverClassName" value="com.mysql.jdbc.Driver" />
- <property name="url" value="jdbc:mysql://localhost:3306/ds_master0" />
- <property name="username" value="root" />
- <property name="password" value="" />
- </bean>
-
- <bean id="ds_master0_slave0"
class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
- <property name="driverClassName" value="com.mysql.jdbc.Driver" />
- <property name="url"
value="jdbc:mysql://localhost:3306/ds_master0_slave0" />
- <property name="username" value="root" />
- <property name="password" value="" />
- </bean>
-
- <bean id="ds_master0_slave1"
class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
- <property name="driverClassName" value="com.mysql.jdbc.Driver" />
- <property name="url"
value="jdbc:mysql://localhost:3306/ds_master0_slave1" />
- <property name="username" value="root" />
- <property name="password" value="" />
- </bean>
-
- <bean id="ds_master1" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
- <property name="driverClassName" value="com.mysql.jdbc.Driver" />
- <property name="url" value="jdbc:mysql://localhost:3306/ds_master1" />
- <property name="username" value="root" />
- <property name="password" value="" />
- </bean>
-
- <bean id="ds_master1_slave0"
class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
- <property name="driverClassName" value="com.mysql.jdbc.Driver" />
- <property name="url"
value="jdbc:mysql://localhost:3306/ds_master1_slave0" />
- <property name="username" value="root" />
- <property name="password" value="" />
- </bean>
-
- <bean id="ds_master1_slave1"
class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
- <property name="driverClassName" value="com.mysql.jdbc.Driver" />
- <property name="url"
value="jdbc:mysql://localhost:3306/ds_master1_slave1" />
- <property name="username" value="root" />
- <property name="password" value="" />
- </bean>
-
- <!-- 4.0.0-RC1 版本 负载均衡策略配置方式 -->
- <!-- <bean id="randomStrategy"
class="org.apache.shardingsphere.example.spring.namespace.algorithm.masterslave.RandomMasterSlaveLoadBalanceAlgorithm"
/> -->
-
- <!-- 4.0.0-RC2 之后版本 负载均衡策略配置方式 -->
- <master-slave:load-balance-algorithm id="randomStrategy" type="RANDOM" />
-
- <sharding:inline-strategy id="databaseStrategy" sharding-column="user_id"
algorithm-expression="ds_ms$->{user_id % 2}" />
- <sharding:inline-strategy id="orderTableStrategy"
sharding-column="order_id" algorithm-expression="t_order$->{order_id % 2}" />
- <sharding:inline-strategy id="orderItemTableStrategy"
sharding-column="order_id" algorithm-expression="t_order_item$->{order_id % 2}"
/>
-
- <sharding:key-generate-strategy id="orderKeyGenerator" type="SNOWFLAKE"
column="order_id" />
- <sharding:key-generate-strategy id="itemKeyGenerator" type="SNOWFLAKE"
column="order_item_id" />
-
- <sharding:data-source id="shardingDataSource">
- <sharding:sharding-rule
data-source-names="ds_master0,ds_master0_slave0,ds_master0_slave1,ds_master1,ds_master1_slave0,ds_master1_slave1">
- <sharding:master-slave-rules>
- <sharding:master-slave-rule id="ds_ms0"
master-data-source-name="ds_master0"
slave-data-source-names="ds_master0_slave0, ds_master0_slave1"
strategy-ref="randomStrategy" />
- <sharding:master-slave-rule id="ds_ms1"
master-data-source-name="ds_master1"
slave-data-source-names="ds_master1_slave0, ds_master1_slave1"
strategy-ref="randomStrategy" />
- </sharding:master-slave-rules>
- <sharding:table-rules>
- <sharding:table-rule logic-table="t_order"
actual-data-nodes="ds_ms$->{0..1}.t_order$->{0..1}"
database-strategy-ref="databaseStrategy"
table-strategy-ref="orderTableStrategy"
key-generate-strategy-ref="orderKeyGenerator" />
- <sharding:table-rule logic-table="t_order_item"
actual-data-nodes="ds_ms$->{0..1}.t_order_item$->{0..1}"
database-strategy-ref="databaseStrategy"
table-strategy-ref="orderItemTableStrategy"
key-generate-strategy-ref="itemKeyGenerator" />
- </sharding:table-rules>
- <sharding:binding-table-rules>
- <sharding:binding-table-rule logic-tables="t_order,
t_order_item" />
- </sharding:binding-table-rules>
- <sharding:broadcast-table-rules>
- <sharding:broadcast-table-rule table="t_config" />
- </sharding:broadcast-table-rules>
- </sharding:sharding-rule>
- </sharding:data-source>
-</beans>
-```
-
-### 数据分片 + 数据加密
-
-```xml
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:p="http://www.springframework.org/schema/p"
- xmlns:context="http://www.springframework.org/schema/context"
-
xmlns:encrypt="http://shardingsphere.apache.org/schema/shardingsphere/encrypt"
- xmlns:tx="http://www.springframework.org/schema/tx"
- xmlns:bean="http://www.springframework.org/schema/util"
-
xmlns:sharding="http://shardingsphere.apache.org/schema/shardingsphere/sharding"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
-
http://www.springframework.org/schema/beans/spring-beans.xsd
-
http://shardingsphere.apache.org/schema/shardingsphere/sharding
-
http://shardingsphere.apache.org/schema/shardingsphere/sharding/sharding.xsd
- http://www.springframework.org/schema/context
-
http://www.springframework.org/schema/context/spring-context.xsd
-
http://shardingsphere.apache.org/schema/shardingsphere/encrypt
-
http://shardingsphere.apache.org/schema/shardingsphere/encrypt/encrypt.xsd
- http://www.springframework.org/schema/tx
- http://www.springframework.org/schema/tx/spring-tx.xsd
- http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util.xsd">
- <import resource="classpath:META-INF/shardingTransaction.xml"/>
- <context:annotation-config />
- <context:component-scan
base-package="org.apache.shardingsphere.example.core.jpa"/>
-
- <bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
- <property name="dataSource" ref="shardingDataSource" />
- <property name="jpaVendorAdapter">
- <bean
class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"
p:database="MYSQL" />
- </property>
- <property name="packagesToScan"
value="org.apache.shardingsphere.example.core.jpa.entity" />
- <property name="jpaProperties">
- <properties>
- <prop
key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
- <prop key="hibernate.hbm2ddl.auto">create-drop</prop>
- <prop key="hibernate.show_sql">true</prop>
- </properties>
- </property>
- </bean>
- <bean id="transactionManager"
class="org.springframework.orm.jpa.JpaTransactionManager"
p:entityManagerFactory-ref="entityManagerFactory" />
- <tx:annotation-driven />
-
- <bean id="demo_ds_0" class="com.zaxxer.hikari.HikariDataSource"
destroy-method="close">
- <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
- <property name="jdbcUrl"
value="jdbc:mysql://localhost:3306/demo_ds_0"/>
- <property name="username" value="root"/>
- <property name="password" value=""/>
- <property name="maximumPoolSize" value="16"/>
- </bean>
-
- <bean id="demo_ds_1" class="com.zaxxer.hikari.HikariDataSource"
destroy-method="close">
- <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
- <property name="jdbcUrl"
value="jdbc:mysql://localhost:3306/demo_ds_1"/>
- <property name="username" value="root"/>
- <property name="password" value=""/>
- <property name="maximumPoolSize" value="16"/>
- </bean>
-
- <sharding:inline-strategy id="databaseStrategy" sharding-column="user_id"
algorithm-expression="demo_ds_${user_id % 2}" />
- <sharding:inline-strategy id="orderTableStrategy"
sharding-column="order_id" algorithm-expression="t_order_${order_id % 2}" />
- <sharding:inline-strategy id="orderItemTableStrategy"
sharding-column="order_id" algorithm-expression="t_order_item_${order_id % 2}"
/>
- <sharding:inline-strategy id="orderEncryptTableStrategy"
sharding-column="order_id" algorithm-expression="t_order_encrypt_${order_id %
2}" />
-
- <sharding:key-generate-strategy id="orderKeyGenerator" type="SNOWFLAKE"
column="order_id" />
- <sharding:key-generate-strategy id="itemKeyGenerator" type="SNOWFLAKE"
column="order_item_id" />
-
- <bean:properties id="dataProtectorProps">
- <prop key="appToken">business</prop>
- </bean:properties>
-
- <encrypt:encrypt-algorithm id="aes_encryptor" type="AES">
- <properties>
- <prop key="aes.key.value">123456</prop>
- </properties>
- </encrypt:encrypt-algorithm>
- <encrypt:encrypt-algorithm id="md5_encryptor" type="MD5" />
-
- <sharding:data-source id="shardingDataSource">
- <sharding:sharding-rule data-source-names="demo_ds_0, demo_ds_1">
- <sharding:table-rules>
- <sharding:table-rule logic-table="t_order"
actual-data-nodes="demo_ds_${0..1}.t_order_${0..1}"
database-strategy-ref="databaseStrategy"
table-strategy-ref="orderTableStrategy"
key-generate-strategy-ref="orderKeyGenerator" />
- <sharding:table-rule logic-table="t_order_item"
actual-data-nodes="demo_ds_${0..1}.t_order_item_${0..1}"
database-strategy-ref="databaseStrategy"
table-strategy-ref="orderItemTableStrategy"
key-generate-strategy-ref="itemKeyGenerator" />
- </sharding:table-rules>
- <sharding:encrypt-rule>
- <encrypt:tables>
- <encrypt:table name="t_order">
- <encrypt:column logic-column="user_id"
cipher-column="user_encrypt" assisted-query-column="user_assisted"
plain-column="user_decrypt" encrypt-algorithm-ref="aes_encryptor" />
- <encrypt:column logic-column="order_id"
cipher-column="order_encrypt" assisted-query-column="order_assisted"
plain-column="order_decrypt" encrypt-algorithm-ref="md5_encryptor" />
- </encrypt:table>
- </encrypt:tables>
- </sharding:encrypt-rule>
- </sharding:sharding-rule>
-
- <sharding:properties>
- <prop key="sql.show">true</prop>
- </sharding:properties>
- </sharding:data-source>
-</beans>
-```
-
-### 治理
-
-```xml
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-
xmlns:orchestration="http://shardingsphere.apache.org/schema/shardingsphere/orchestration"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
-
http://www.springframework.org/schema/beans/spring-beans.xsd
-
http://shardingsphere.apache.org/schema/shardingsphere/orchestration
-
http://shardingsphere.apache.org/schema/shardingsphere/orchestration/orchestration.xsd">
-
- <util:properties id="instance-properties">
- <prop key="max-retries">3</prop>
- <prop key="operation-timeout-milliseconds">3000</prop>
- </util:properties>
- <orchestration:instance id="regCenter"
orchestration-type="registry_center,config_center,metadata_center"
instance-type="zookeeper" server-lists="localhost:2181"
namespace="orchestration-spring-namespace-demo"
- properties-ref="instance-properties" />
- <orchestration:data-source id="shardingDatabasesTablesDataSource"
data-source-ref="realShardingDatabasesTablesDataSource"
instance-ref="regCenter" overwrite="true" />
- <orchestration:slave-data-source id="masterSlaveDataSource"
data-source-ref="realMasterSlaveDataSource" instance-ref="regCenter"
overwrite="true" />
- <orchestration:data-source id="encryptDataSource"
data-source-ref="realEncryptDataSource" instance-ref="regCenter"
overwrite="true" />
-</beans>
-```
-
-## 配置项说明
-
-### 分库分表
-
-命名空间:http://shardingsphere.apache.org/schema/shardingsphere/sharding/sharding.xsd
-
-#### \<sharding:data-source />
-
-| *名称* | *类型* | *说明* |
-| -------------- | ----- | -------------- |
-| id | 属性 | Spring Bean Id |
-| sharding-rule | 标签 | 数据分片配置规则 |
-| properties (?) | 标签 | 属性配置 |
-
-#### \<sharding:sharding-rule />
-
-| *名称* | *类型* | *说明*
|
-| ------------------------------------- | ----- |
------------------------------------------------------------------------------------------------------
|
-| data-source-names | 属性 | 数据源Bean列表,多个Bean以逗号分隔
|
-| table-rules | 标签 | 表分片规则配置对象
|
-| binding-table-rules (?) | 标签 | 绑定表规则列表
|
-| broadcast-table-rules (?) | 标签 | 广播表规则列表
|
-| default-data-source-name (?) | 属性 | 未配置分片规则的表将通过默认数据源定位
|
-| default-database-strategy-ref (?) | 属性 |
默认数据库分片策略,对应\<sharding:xxx-strategy>中的策略Id,缺省表示不分库
|
-| default-table-strategy-ref (?) | 属性 |
默认表分片策略,对应\<sharding:xxx-strategy>中的策略Id,缺省表示不分表
|
-| default-key-generate-strategy-ref (?) | 属性 |
默认自增列值生成器引用,缺省使用`org.apache.shardingsphere.core.keygen.generator.impl.SnowflakeKeyGenerator`
|
-| encrypt-rule (?) | 标签 | 加密规则
|
-
-#### \<sharding:table-rules />
-
-| *名称* | *类型* | *说明* |
-| -------------- | ----- | --------------- |
-| table-rule (+) | 标签 | 表分片规则配置对象 |
-
-#### \<sharding:table-rule />
-
-| *名称* | *类型* | *说明*
|
-| ----------------------------- | ----- |
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-| logic-table | 属性 | 逻辑表名称
|
-| actual-data-nodes (?) | 属性 | 由数据源名 +
表名组成,以小数点分隔。多个表以逗号分隔,支持inline表达式。缺省表示使用已知数据源与逻辑表名称生成数据节点,用于广播表(即每个库中都需要一个同样的表用于关联查询,多为字典表)或只分库不分表且所有库的表结构完全一致的情况
|
-| database-strategy-ref (?) | 属性 |
数据库分片策略,对应\<sharding:xxx-strategy>中的策略Id,缺省表示使用\<sharding:sharding-rule
/>配置的默认数据库分片策略
|
-| table-strategy-ref (?) | 属性 |
表分片策略,对应\<sharding:xxx-strategy>中的策略Id,缺省表示使用\<sharding:sharding-rule
/>配置的默认表分片策略
|
-| key-generate-strategy-ref (?) | 属性 | 自增列值生成器引用,缺省表示使用默认自增列值生成器
|
-
-#### \<sharding:binding-table-rules />
-
-| *名称* | *类型* | *说明* |
-| ---------------------- | ----- | -------- |
-| binding-table-rule (+) | 标签 | 绑定表规则 |
-
-#### \<sharding:binding-table-rule />
-
-| *名称* | *类型* | *说明* |
-| ------------ | ----- | ----------------------------- |
-| logic-tables | 属性 | 绑定规则的逻辑表名,多表以逗号分隔 |
-
-#### \<sharding:broadcast-table-rules />
-
-| *名称* | *类型* | *说明* |
-| ------------------------ | ----- | -------- |
-| broadcast-table-rule (+) | 标签 | 广播表规则 |
-
-#### \<sharding:broadcast-table-rule />
-
-| *名称* | *类型* | *说明 |
-| ------ | ----- | --------------- |
-| table | 属性 | 广播规则的表名 |
-
-#### \<sharding:standard-strategy />
-
-| *名称* | *类型* | *说明*
|
-| ----------------------- | ------ |
------------------------------------------------------------- |
-| id | 属性 | Spring Bean Id
|
-| sharding-column | 属性 | 分片列名称
|
-| precise-algorithm-ref | 属性 |
精确分片算法引用,用于=和IN。该类需实现PreciseShardingAlgorithm接口 |
-| range-algorithm-ref (?) | 属性 |
范围分片算法引用,用于BETWEEN。该类需实现RangeShardingAlgorithm接口 |
-
-#### \<sharding:complex-strategy />
-
-| *名称* | *类型* | *说明*
|
-| --------------- | ------ |
-------------------------------------------------------- |
-| id | 属性 | Spring Bean Id
|
-| sharding-columns | 属性 | 分片列名称,多个列以逗号分隔 |
-| algorithm-ref | 属性 | 复合分片算法引用。该类需实现ComplexKeysShardingAlgorithm接口 |
-
-#### \<sharding:inline-strategy />
-
-| *名称* | *类型* | *说明* |
-| -------------------- | ----- | ------------------------------ |
-| id | 属性 | Spring Bean Id |
-| sharding-column | 属性 | 分片列名称 |
-| algorithm-expression | 属性 | 分片算法行表达式,需符合groovy语法 |
-
-#### \<sharding:hint-database-strategy />
-
-| *名称* | *类型* | *说明* |
-| ------------- | ----- | ---------------------------------------------- |
-| id | 属性 | Spring Bean Id |
-| algorithm-ref | 属性 | Hint分片算法。该类需实现HintShardingAlgorithm接口 |
-
-#### \<sharding:none-strategy />
-
-| *名称* | *类型* | *说明* |
-| ----- | ------ | -------------- |
-| id | 属性 | Spring Bean Id |
-
-#### \<sharding:key-generate-strategy />
-
-| *名称* | *类型* | *说明*
|
-| ----------------- | ---------------------------- |
-------------------------------------------------------------------------------
|
-| column | 属性 | 自增列名称
|
-| type | 属性 |
自增列值生成器类型,可自定义或选择内置类型:SNOWFLAKE/UUID |
-| properties-ref | 属性 | 自增列值生成器的属性配置引用 |
-
-#### Properties
-
-属性配置项,可以为以下自增列值生成器的属性。
-
-##### SNOWFLAKE
-
-| *名称* | *数据类型* | *说明*
|
-| --------------------------------------------------- | ---------- |
-------------------------------------------------------------------------------------------------------
|
-| worker.id (?) | long |
工作机器唯一id,默认为0
|
-| max.tolerate.time.difference.milliseconds (?) | long |
最大容忍时钟回退时间,单位:毫秒。默认为10毫秒
|
-| max.vibration.offset (?) | int |
最大抖动上限值,范围[0, 4096),默认为1。注:若使用此算法生成值作分片值,建议配置此属性。此算法在不同毫秒内所生成的key取模2^n
(2^n一般为分库或分表数) 之后结果总为0或1。为防止上述分片问题,建议将此属性值配置为(2^n)-1 |
-
-#### \<sharding:encrypt-rule />
-
-| *名称* | *类型* | *说明*
|
-| ------------------------- | ---------------------- |
-------------------------------------- |
-| encrypt:encrypt-rule(?) | 标签 | 加解密规则
|
-
-#### \<sharding:properties />
-
-| *名称* | *类型* | *说明*
|
-| -----------------------------------| ----- |
---------------------------------------------- |
-| sql.show (?) | 属性 | 是否开启SQL显示,默认值: false
|
-| executor.size (?) | 属性 | 工作线程数量,默认值: CPU核数
|
-| max.connections.size.per.query (?) | 属性 | 每个物理数据库为每次查询分配的最大连接数量。默认值: 1 |
-| check.table.metadata.enabled (?) | 属性 | 是否在启动时检查分表元数据一致性,默认值: false
|
-| query.with.cipher.column (?) | 属性 | 当存在明文列时,是否使用密文列查询,默认值: true |
-
-### 读写分离
-
-命名空间:http://shardingsphere.apache.org/schema/shardingsphere/masterslave/master-slave.xsd
-
-#### \<master-slave:data-source />
-
-| *名称* | *类型* | *说明*
|
-| ----------------------- | ----- |
---------------------------------------------------------------------------- |
-| id | 属性 | Spring Bean Id
|
-| master-data-source-name | 属性 | 主库数据源Bean Id
|
-| slave-data-source-names | 属性 | 从库数据源Bean Id列表,多个Bean以逗号分隔
|
-| strategy-ref (?) | 属性 |
从库负载均衡算法引用。该类需实现MasterSlaveLoadBalanceAlgorithm接口 |
-| strategy-type (?) | 属性 |
从库负载均衡算法类型,可选值:ROUND_ROBIN,RANDOM。若`strategy-ref`存在则忽略该配置 |
-| properties (?) | 标签 | 属性配置
|
-
-#### \<master-slave:properties />
-
-| *名称* | *类型* | *说明*
|
-| -----------------------------------| ----- |
---------------------------------------------- |
-| sql.show (?) | 属性 | 是否开启SQL显示,默认值: false
|
-| executor.size (?) | 属性 | 工作线程数量,默认值: CPU核数
|
-| max.connections.size.per.query (?) | 属性 | 每个物理数据库为每次查询分配的最大连接数量。默认值: 1 |
-| check.table.metadata.enabled (?) | 属性 | 是否在启动时检查分表元数据一致性,默认值: false
|
-
-#### \<master-slave:load-balance-algorithm />
-
-4.0.0-RC2 版本 添加
-
-| *名称* | *类型* | *说明*
|
-| -----------------------------------| ------ |
---------------------------------------------- |
-| id | 属性 | Spring Bean Id
|
-| type | 属性 |
负载均衡算法类型,'RANDOM'或'ROUND_ROBIN',支持自定义拓展|
-| properties-ref (?) | 属性 | 负载均衡算法配置参数
|
-
-### 数据加密
-
-命名空间:http://shardingsphere.apache.org/schema/shardingsphere/encrypt/encrypt.xsd
-
-#### \<encrypt:data-source />
-
-| *名称* | *类型* | *说明* |
-| ----------------------- | ----- |
-------------------------------------------- |
-| id | 属性 | Spring Bean Id
|
-| data-source-name | 属性 | 加密数据源Bean Id |
-| properties (?) | 标签 | 属性配置
|
-
-#### \<encrypt:encrypt-algorithm />
-
-| *名称* | *类型* | *说明*
|
-| --------- | ----- |
------------------------------------------------------------------------ |
-| id | 属性 | 加密算法的名称
|
-| type | 属性 | 加解密算法类型,可自定义或选择内置类型:MD5/AES
|
-| properties-ref | 属性 | 属性配置, 注意:使用AES加密算法,需要配置 AES 加密算法的 KEY
属性:aes.key.value |
-
-#### \<encrypt:tables />
-
-| *名称* | *类型* | *说明* |
-| ----------------------- | ----- | ------------ |
-| table(+) | 标签 | 加密表规则配置 |
-
-#### \<encrypt:table />
-
-| *名称* | *类型* | *说明* |
-| ----------------------- | ----- | ------------ |
-| column(+) | 标签 | 加密列规则配置 |
-
-#### \<encrypt:column />
-
-| *名称* | *类型* | *说明*
|
-| ----------------------- | ----- |
---------------------------------------------------------------------- |
-| logic-column | 属性 | 逻辑列名
|
-| plain-column | 属性 | 存储明文的字段
|
-| cipher-column | 属性 | 存储密文的字段
|
-| assisted-query-columns | 属性 | 辅助查询字段,针对 QueryAssistedEncryptAlgorithm
类型的加解密算法进行辅助查询 |
-
-#### \<encrypt:properties />
-
-| *名称* | *类型* | *说明*
|
-| -----------------------------------| ----- |
---------------------------------------------- |
-| sql.show (?) | 属性 | 是否开启SQL显示,默认值: false
|
-| query.with.cipher.column (?) | 属性 | 当存在明文列时,是否使用密文列查询,默认值: true |
-
-### 数据分片 + 治理
-
-命名空间:http://shardingsphere.apache.org/schema/shardingsphere/orchestration/orchestration.xsd
-
-#### \<orchestration:sharding-data-source />
-
-| *名称* | *类型* | *说明*
|
-| ------------------- | ----- |
------------------------------------------------------------------------ |
-| id | 属性 | ID
|
-| data-source-ref (?) | 属性 | 被治理的数据库id
|
-| instance-ref | 属性 | 治理实例id
|
-| overwrite | 属性 | 本地配置是否覆盖配置中心配置。如果可覆盖,每次启动都以本地配置为准。缺省为不覆盖 |
-
-### 读写分离 + 治理
-
-命名空间:http://shardingsphere.apache.org/schema/shardingsphere/orchestration/orchestration.xsd
-
-#### \<orchestration:master-slave-data-source />
-
-| *名称* | *类型* | *说明*
|
-| ------------------- | ----- |
---------------------------------------------------------------------- |
-| id | 属性 | ID
|
-| data-source-ref (?) | 属性 | 被治理的数据库id
|
-| instance-ref | 属性 | 治理实例id
|
-| overwrite | 属性 | 本地配置是否覆盖配置中心配置。如果可覆盖,每次启动都以本地配置为准。缺省为不覆盖 |
-
-### 数据加密 + 治理
-
-命名空间:http://shardingsphere.apache.org/schema/shardingsphere/orchestration/orchestration.xsd
-
-#### \<orchestration:encrypt-data-source />
-
-| *名称* | *类型* | *说明*
|
-| ------------------- | ----- |
---------------------------------------------------------------------- |
-| id | 属性 | ID
|
-| data-source-ref (?) | 属性 | 被治理的数据库id
|
-| instance-ref | 属性 | 治理实例id
|
-| overwrite | 属性 | 本地配置是否覆盖配置中心配置。如果可覆盖,每次启动都以本地配置为准。缺省为不覆盖 |
-
-### 治理实例配置
-
-命名空间:http://shardingsphere.apache.org/schema/shardingsphere/orchestration/orchestration.xsd
-
-#### \<orchestration:instance />
-
-| *名称* | *类型* | *说明*
|
-| ----------------------------------- | ----- |
------------------------------------------------------------------------------------------|
-| id | 属性 | 配置/注册/元数据中心的Spring Bean Id
|
-| instance-type | 属性 | 配置/注册/元数据中心实例类型。如:zookeeper
|
-| orchestration-type | 属性 |
治理类型,例如config_center/registry_center/metadata_center |
-| server-lists | 属性 |
连接配置/注册/元数据中心服务器的列表,包括IP地址和端口号,多个地址用逗号分隔。如: host1:2181,host2:2181 |
-| namespace (?) | 属性 | 配置/注册/元数据中心的命名空间
|
-| properties-ref (?) | 属性 | 配置中心其它属性
|
diff --git
a/docs/document/content/user-manual/shardingsphere-jdbc/configuration/config-spring-namespace.en.md
b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/config-spring-namespace.en.md
deleted file mode 100644
index c47964f..0000000
---
a/docs/document/content/user-manual/shardingsphere-jdbc/configuration/config-spring-namespace.en.md
+++ /dev/null
@@ -1,753 +0,0 @@
-+++
-title = "Spring Namespace Configuration"
-weight = 4
-+++
-
-## Notice
-
-Inline expression identifier can can use `${...} ` or `$->{...}`, but the
former one clashes with the placeholder in property documents of Spring, so it
is suggested to use `$->{...}` for inline expression identifier under Spring
environment.
-
-## Example
-
-example:
[shardingsphere-example](https://github.com/apache/shardingsphere/tree/master/examples/shardingsphere-jdbc-example/sharding-example/sharding-spring-namespace-jpa-example)
-
-### Sharding
-
-```xml
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:p="http://www.springframework.org/schema/p"
- xmlns:context="http://www.springframework.org/schema/context"
- xmlns:tx="http://www.springframework.org/schema/tx"
-
xmlns:sharding="http://shardingsphere.apache.org/schema/shardingsphere/sharding"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
-
http://www.springframework.org/schema/beans/spring-beans.xsd
-
http://shardingsphere.apache.org/schema/shardingsphere/sharding
-
http://shardingsphere.apache.org/schema/shardingsphere/sharding/sharding.xsd
- http://www.springframework.org/schema/context
-
http://www.springframework.org/schema/context/spring-context.xsd
- http://www.springframework.org/schema/tx
-
http://www.springframework.org/schema/tx/spring-tx.xsd">
- <context:annotation-config />
-
- <bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
- <property name="dataSource" ref="shardingDataSource" />
- <property name="jpaVendorAdapter">
- <bean
class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"
p:database="MYSQL" />
- </property>
- <property name="packagesToScan"
value="org.apache.shardingsphere.example.core.jpa.entity" />
- <property name="jpaProperties">
- <properties>
- <prop
key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
- <prop key="hibernate.hbm2ddl.auto">create</prop>
- <prop key="hibernate.show_sql">true</prop>
- </properties>
- </property>
- </bean>
- <bean id="transactionManager"
class="org.springframework.orm.jpa.JpaTransactionManager"
p:entityManagerFactory-ref="entityManagerFactory" />
- <tx:annotation-driven />
-
- <bean id="ds0" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
- <property name="driverClassName" value="com.mysql.jdbc.Driver" />
- <property name="url" value="jdbc:mysql://localhost:3306/ds0" />
- <property name="username" value="root" />
- <property name="password" value="" />
- </bean>
-
- <bean id="ds1" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
- <property name="driverClassName" value="com.mysql.jdbc.Driver" />
- <property name="url" value="jdbc:mysql://localhost:3306/ds1" />
- <property name="username" value="root" />
- <property name="password" value="" />
- </bean>
-
- <bean id="preciseModuloDatabaseShardingAlgorithm"
class="org.apache.shardingsphere.example.algorithm.PreciseModuloShardingDatabaseAlgorithm"
/>
- <bean id="preciseModuloTableShardingAlgorithm"
class="org.apache.shardingsphere.example.algorithm.PreciseModuloShardingTableAlgorithm"
/>
-
- <sharding:standard-strategy id="databaseShardingStrategy"
sharding-column="user_id"
precise-algorithm-ref="preciseModuloDatabaseShardingAlgorithm" />
- <sharding:standard-strategy id="tableShardingStrategy"
sharding-column="order_id"
precise-algorithm-ref="preciseModuloTableShardingAlgorithm" />
-
- <sharding:key-generate-strategy id="orderKeyGenerator" type="SNOWFLAKE"
column="order_id" />
- <sharding:key-generate-strategy id="itemKeyGenerator" type="SNOWFLAKE"
column="order_item_id" />
-
- <sharding:data-source id="shardingDataSource">
- <sharding:sharding-rule data-source-names="ds0,ds1">
- <sharding:table-rules>
- <sharding:table-rule logic-table="t_order"
actual-data-nodes="ds$->{0..1}.t_order$->{0..1}"
database-strategy-ref="databaseShardingStrategy"
table-strategy-ref="tableShardingStrategy"
key-generate-strategy-ref="orderKeyGenerator" />
- <sharding:table-rule logic-table="t_order_item"
actual-data-nodes="ds$->{0..1}.t_order_item$->{0..1}"
database-strategy-ref="databaseShardingStrategy"
table-strategy-ref="tableShardingStrategy"
key-generate-strategy-ref="itemKeyGenerator" />
- </sharding:table-rules>
- <sharding:binding-table-rules>
- <sharding:binding-table-rule logic-tables="t_order,
t_order_item" />
- </sharding:binding-table-rules>
- <sharding:broadcast-table-rules>
- <sharding:broadcast-table-rule table="t_config" />
- </sharding:broadcast-table-rules>
- </sharding:sharding-rule>
- </sharding:data-source>
-</beans>
-```
-
-### Read-Write Split
-
-```xml
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:context="http://www.springframework.org/schema/context"
- xmlns:p="http://www.springframework.org/schema/p"
- xmlns:tx="http://www.springframework.org/schema/tx"
-
xmlns:master-slave="http://shardingsphere.apache.org/schema/shardingsphere/masterslave"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
-
http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/context
-
http://www.springframework.org/schema/context/spring-context.xsd
- http://www.springframework.org/schema/tx
- http://www.springframework.org/schema/tx/spring-tx.xsd
-
http://shardingsphere.apache.org/schema/shardingsphere/masterslave
-
http://shardingsphere.apache.org/schema/shardingsphere/masterslave/master-slave.xsd">
- <context:annotation-config />
- <context:component-scan
base-package="org.apache.shardingsphere.example.core.jpa" />
-
- <bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
- <property name="dataSource" ref="masterSlaveDataSource" />
- <property name="jpaVendorAdapter">
- <bean
class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"
p:database="MYSQL" />
- </property>
- <property name="packagesToScan"
value="org.apache.shardingsphere.example.core.jpa.entity" />
- <property name="jpaProperties">
- <properties>
- <prop
key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
- <prop key="hibernate.hbm2ddl.auto">create</prop>
- <prop key="hibernate.show_sql">true</prop>
- </properties>
- </property>
- </bean>
- <bean id="transactionManager"
class="org.springframework.orm.jpa.JpaTransactionManager"
p:entityManagerFactory-ref="entityManagerFactory" />
- <tx:annotation-driven />
-
- <bean id="ds_master" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
- <property name="driverClassName" value="com.mysql.jdbc.Driver" />
- <property name="url" value="jdbc:mysql://localhost:3306/ds_master" />
- <property name="username" value="root" />
- <property name="password" value="" />
- </bean>
-
- <bean id="ds_slave0" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
- <property name="driverClassName" value="com.mysql.jdbc.Driver" />
- <property name="url" value="jdbc:mysql://localhost:3306/ds_slave0" />
- <property name="username" value="root" />
- <property name="password" value="" />
- </bean>
-
- <bean id="ds_slave1" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
- <property name="driverClassName" value="com.mysql.jdbc.Driver" />
- <property name="url" value="jdbc:mysql://localhost:3306/ds_slave1" />
- <property name="username" value="root" />
- <property name="password" value="" />
- </bean>
-
- <!-- 4.0.0-RC1 version load balance algorithm configuration -->
- <!-- <bean id="randomStrategy"
class="org.apache.shardingsphere.example.spring.namespace.algorithm.masterslave.RandomMasterSlaveLoadBalanceAlgorithm"
/> -->
-
- <!-- 4.0.0-RC2 and later version load balance algorithm configuration -->
- <master-slave:load-balance-algorithm id="randomStrategy" type="RANDOM" />
-
- <master-slave:data-source id="masterSlaveDataSource"
master-data-source-name="ds_master" slave-data-source-names="ds_slave0,
ds_slave1" strategy-ref="randomStrategy">
- <master-slave:properties>
- <prop key="sql.show">true</prop>
- <prop key="executor.size">10</prop>
- <prop key="foo">bar</prop>
- </master-slave:properties>
- </master-slave:data-source>
-</beans>
-```
-
-### data encryption
-
-```xml
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-
xmlns:encrypt="http://shardingsphere.apache.org/schema/shardingsphere/encrypt"
- xmlns:bean="http://www.springframework.org/schema/util"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
-
http://www.springframework.org/schema/beans/spring-beans.xsd
-
http://shardingsphere.apache.org/schema/shardingsphere/encrypt
-
http://shardingsphere.apache.org/schema/shardingsphere/encrypt/encrypt.xsd
- http://www.springframework.org/schema/util
-
http://www.springframework.org/schema/util/spring-util.xsd">
-
- <bean id="ds" class="com.zaxxer.hikari.HikariDataSource"
destroy-method="close">
- <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
- <property name="jdbcUrl"
value="jdbc:mysql://localhost:3306/demo_ds?useSSL=false&useUnicode=true&characterEncoding=UTF-8"/>
- <property name="username" value="root"/>
- <property name="password" value=""/>
- </bean>
-
- <bean:properties id="properties">
- <prop key="aes.key.value">123456</prop>
- </bean:properties>
-
- <encrypt:encrypt-algorithm id="aes_encryptor" type="AES">
- <properties>
- <prop key="aes.key.value">123456</prop>
- </properties>
- </encrypt:encrypt-algorithm>
- <encrypt:encrypt-algorithm id="md5_encryptor" type="MD5" />
-
- <encrypt:data-source id="encryptDataSource" data-source-name="ds" >
- <encrypt:encrypt-rule>
- <encrypt:tables>
- <encrypt:table name="t_order">
- <encrypt:column logic-column="user_id"
cipher-column="user_encrypt" assisted-query-column="user_assisted"
plain-column="user_decrypt" encrypt-algorithm-ref="aes_encryptor" />
- <encrypt:column logic-column="order_id"
cipher-column="order_encrypt" assisted-query-column="order_assisted"
plain-column="order_decrypt" encrypt-algorithm-ref="md5_encryptor"/>
- </encrypt:table>
- </encrypt:tables>
- </encrypt:encrypt-rule>
- <encrypt:properties>
- <prop key="sql.show">true</prop>
- <prop key="query.with.cipher.column">true</prop>
- </encrypt:properties>
- </encrypt:data-source>
- </beans>
-```
-
-### Sharding + Read-write splitting
-
-```xml
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:p="http://www.springframework.org/schema/p"
- xmlns:context="http://www.springframework.org/schema/context"
- xmlns:tx="http://www.springframework.org/schema/tx"
-
xmlns:sharding="http://shardingsphere.apache.org/schema/shardingsphere/sharding"
-
xmlns:master-slave="http://shardingsphere.apache.org/schema/shardingsphere/masterslave"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
-
http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/context
-
http://www.springframework.org/schema/context/spring-context.xsd
- http://www.springframework.org/schema/tx
- http://www.springframework.org/schema/tx/spring-tx.xsd
-
http://shardingsphere.apache.org/schema/shardingsphere/sharding
-
http://shardingsphere.apache.org/schema/shardingsphere/sharding/sharding.xsd
-
http://shardingsphere.apache.org/schema/shardingsphere/masterslave
-
http://shardingsphere.apache.org/schema/shardingsphere/masterslave/master-slave.xsd">
- <context:annotation-config />
- <context:component-scan
base-package="org.apache.shardingsphere.example.core.jpa" />
-
- <bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
- <property name="dataSource" ref="shardingDataSource" />
- <property name="jpaVendorAdapter">
- <bean
class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"
p:database="MYSQL" />
- </property>
- <property name="packagesToScan"
value="org.apache.shardingsphere.example.core.jpa.entity" />
- <property name="jpaProperties">
- <properties>
- <prop
key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
- <prop key="hibernate.hbm2ddl.auto">create</prop>
- <prop key="hibernate.show_sql">true</prop>
- </properties>
- </property>
- </bean>
- <bean id="transactionManager"
class="org.springframework.orm.jpa.JpaTransactionManager"
p:entityManagerFactory-ref="entityManagerFactory" />
- <tx:annotation-driven />
-
- <bean id="ds_master0" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
- <property name="driverClassName" value="com.mysql.jdbc.Driver" />
- <property name="url" value="jdbc:mysql://localhost:3306/ds_master0" />
- <property name="username" value="root" />
- <property name="password" value="" />
- </bean>
-
- <bean id="ds_master0_slave0"
class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
- <property name="driverClassName" value="com.mysql.jdbc.Driver" />
- <property name="url"
value="jdbc:mysql://localhost:3306/ds_master0_slave0" />
- <property name="username" value="root" />
- <property name="password" value="" />
- </bean>
-
- <bean id="ds_master0_slave1"
class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
- <property name="driverClassName" value="com.mysql.jdbc.Driver" />
- <property name="url"
value="jdbc:mysql://localhost:3306/ds_master0_slave1" />
- <property name="username" value="root" />
- <property name="password" value="" />
- </bean>
-
- <bean id="ds_master1" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
- <property name="driverClassName" value="com.mysql.jdbc.Driver" />
- <property name="url" value="jdbc:mysql://localhost:3306/ds_master1" />
- <property name="username" value="root" />
- <property name="password" value="" />
- </bean>
-
- <bean id="ds_master1_slave0"
class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
- <property name="driverClassName" value="com.mysql.jdbc.Driver" />
- <property name="url"
value="jdbc:mysql://localhost:3306/ds_master1_slave0" />
- <property name="username" value="root" />
- <property name="password" value="" />
- </bean>
-
- <bean id="ds_master1_slave1"
class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
- <property name="driverClassName" value="com.mysql.jdbc.Driver" />
- <property name="url"
value="jdbc:mysql://localhost:3306/ds_master1_slave1" />
- <property name="username" value="root" />
- <property name="password" value="" />
- </bean>
-
- <!-- 4.0.0-RC1 version load balance algorithm configuration -->
- <!-- <bean id="randomStrategy"
class="org.apache.shardingsphere.example.spring.namespace.algorithm.masterslave.RandomMasterSlaveLoadBalanceAlgorithm"
/> -->
-
- <!-- 4.0.0-RC2 and later version load balance algorithm configuration -->
- <master-slave:load-balance-algorithm id="randomStrategy" type="RANDOM" />
-
- <sharding:inline-strategy id="databaseStrategy" sharding-column="user_id"
algorithm-expression="ds_ms$->{user_id % 2}" />
- <sharding:inline-strategy id="orderTableStrategy"
sharding-column="order_id" algorithm-expression="t_order$->{order_id % 2}" />
- <sharding:inline-strategy id="orderItemTableStrategy"
sharding-column="order_id" algorithm-expression="t_order_item$->{order_id % 2}"
/>
-
- <bean id="snowflakeAlgorithm" class="KeyGenerateAlgorithmFactoryBean">
- <property name="type" value="SNOWFLAKE" />
- </bean>
-
- <sharding:key-generate-strategy id="orderKeyGenerator" column="order_id"
algorithm-ref="snowflakeAlgorithm" />
- <sharding:key-generate-strategy id="itemKeyGenerator"
column="order_item_id" algorithm-ref="snowflakeAlgorithm" />
-
- <sharding:data-source id="shardingDataSource">
- <sharding:sharding-rule
data-source-names="ds_master0,ds_master0_slave0,ds_master0_slave1,ds_master1,ds_master1_slave0,ds_master1_slave1">
- <sharding:master-slave-rules>
- <sharding:master-slave-rule id="ds_ms0"
master-data-source-name="ds_master0"
slave-data-source-names="ds_master0_slave0, ds_master0_slave1"
strategy-ref="randomStrategy" />
- <sharding:master-slave-rule id="ds_ms1"
master-data-source-name="ds_master1"
slave-data-source-names="ds_master1_slave0, ds_master1_slave1"
strategy-ref="randomStrategy" />
- </sharding:master-slave-rules>
- <sharding:table-rules>
- <sharding:table-rule logic-table="t_order"
actual-data-nodes="ds_ms$->{0..1}.t_order$->{0..1}"
database-strategy-ref="databaseStrategy"
table-strategy-ref="orderTableStrategy"
key-generate-strategy-ref="orderKeyGenerator" />
- <sharding:table-rule logic-table="t_order_item"
actual-data-nodes="ds_ms$->{0..1}.t_order_item$->{0..1}"
database-strategy-ref="databaseStrategy"
table-strategy-ref="orderItemTableStrategy"
key-generate-strategy-ref="itemKeyGenerator" />
- </sharding:table-rules>
- <sharding:binding-table-rules>
- <sharding:binding-table-rule logic-tables="t_order,
t_order_item" />
- </sharding:binding-table-rules>
- <sharding:broadcast-table-rules>
- <sharding:broadcast-table-rule table="t_config" />
- </sharding:broadcast-table-rules>
- </sharding:sharding-rule>
- </sharding:data-source>
-</beans>
-```
-
-### Sharding + data encryption
-
-```xml
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:p="http://www.springframework.org/schema/p"
- xmlns:context="http://www.springframework.org/schema/context"
-
xmlns:encrypt="http://shardingsphere.apache.org/schema/shardingsphere/encrypt"
- xmlns:tx="http://www.springframework.org/schema/tx"
- xmlns:bean="http://www.springframework.org/schema/util"
-
xmlns:sharding="http://shardingsphere.apache.org/schema/shardingsphere/sharding"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
-
http://www.springframework.org/schema/beans/spring-beans.xsd
-
http://shardingsphere.apache.org/schema/shardingsphere/sharding
-
http://shardingsphere.apache.org/schema/shardingsphere/sharding/sharding.xsd
- http://www.springframework.org/schema/context
-
http://www.springframework.org/schema/context/spring-context.xsd
-
http://shardingsphere.apache.org/schema/shardingsphere/encrypt
-
http://shardingsphere.apache.org/schema/shardingsphere/encrypt/encrypt.xsd
- http://www.springframework.org/schema/tx
- http://www.springframework.org/schema/tx/spring-tx.xsd
- http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util.xsd">
- <import resource="classpath:META-INF/shardingTransaction.xml"/>
- <context:annotation-config />
- <context:component-scan
base-package="org.apache.shardingsphere.example.core.jpa"/>
-
- <bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
- <property name="dataSource" ref="shardingDataSource" />
- <property name="jpaVendorAdapter">
- <bean
class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"
p:database="MYSQL" />
- </property>
- <property name="packagesToScan"
value="org.apache.shardingsphere.example.core.jpa.entity" />
- <property name="jpaProperties">
- <properties>
- <prop
key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
- <prop key="hibernate.hbm2ddl.auto">create-drop</prop>
- <prop key="hibernate.show_sql">true</prop>
- </properties>
- </property>
- </bean>
- <bean id="transactionManager"
class="org.springframework.orm.jpa.JpaTransactionManager"
p:entityManagerFactory-ref="entityManagerFactory" />
- <tx:annotation-driven />
-
- <bean id="demo_ds_0" class="com.zaxxer.hikari.HikariDataSource"
destroy-method="close">
- <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
- <property name="jdbcUrl"
value="jdbc:mysql://localhost:3306/demo_ds_0"/>
- <property name="username" value="root"/>
- <property name="password" value=""/>
- <property name="maximumPoolSize" value="16"/>
- </bean>
-
- <bean id="demo_ds_1" class="com.zaxxer.hikari.HikariDataSource"
destroy-method="close">
- <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
- <property name="jdbcUrl"
value="jdbc:mysql://localhost:3306/demo_ds_1"/>
- <property name="username" value="root"/>
- <property name="password" value=""/>
- <property name="maximumPoolSize" value="16"/>
- </bean>
-
- <sharding:inline-strategy id="databaseStrategy" sharding-column="user_id"
algorithm-expression="demo_ds_${user_id % 2}" />
- <sharding:inline-strategy id="orderTableStrategy"
sharding-column="order_id" algorithm-expression="t_order_${order_id % 2}" />
- <sharding:inline-strategy id="orderItemTableStrategy"
sharding-column="order_id" algorithm-expression="t_order_item_${order_id % 2}"
/>
- <sharding:inline-strategy id="orderEncryptTableStrategy"
sharding-column="order_id" algorithm-expression="t_order_encrypt_${order_id %
2}" />
-
- <sharding:key-generate-strategy id="orderKeyGenerator" type="SNOWFLAKE"
column="order_id" />
- <sharding:key-generate-strategy id="itemKeyGenerator" type="SNOWFLAKE"
column="order_item_id" />
-
- <bean:properties id="dataProtectorProps">
- <prop key="appToken">business</prop>
- </bean:properties>
-
- <encrypt:encrypt-algorithm id="aes_encryptor" type="AES">
- <properties>
- <prop key="aes.key.value">123456</prop>
- </properties>
- </encrypt:encrypt-algorithm>
- <encrypt:encrypt-algorithm id="md5_encryptor" type="MD5" />
-
- <sharding:data-source id="shardingDataSource">
- <sharding:sharding-rule data-source-names="demo_ds_0, demo_ds_1">
- <sharding:table-rules>
- <sharding:table-rule logic-table="t_order"
actual-data-nodes="demo_ds_${0..1}.t_order_${0..1}"
database-strategy-ref="databaseStrategy"
table-strategy-ref="orderTableStrategy"
key-generate-strategy-ref="orderKeyGenerator" />
- <sharding:table-rule logic-table="t_order_item"
actual-data-nodes="demo_ds_${0..1}.t_order_item_${0..1}"
database-strategy-ref="databaseStrategy"
table-strategy-ref="orderItemTableStrategy"
key-generate-strategy-ref="itemKeyGenerator" />
- </sharding:table-rules>
- <sharding:encrypt-rule>
- <encrypt:tables>
- <encrypt:table name="t_order">
- <encrypt:column logic-column="user_id"
cipher-column="user_encrypt" assisted-query-column="user_assisted"
plain-column="user_decrypt" encrypt-algorithm-ref="aes_encryptor" />
- <encrypt:column logic-column="order_id"
cipher-column="order_encrypt" assisted-query-column="order_assisted"
plain-column="order_decrypt" encrypt-algorithm-ref="md5_encryptor" />
- </encrypt:table>
- </encrypt:tables>
- </sharding:encrypt-rule>
- </sharding:sharding-rule>
-
- <sharding:properties>
- <prop key="sql.show">true</prop>
- </sharding:properties>
- </sharding:data-source>
-</beans>
-```
-
-
-### Orchestration
-
-```xml
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-
xmlns:sharding="http://shardingsphere.apache.org/schema/shardingsphere/orchestration/sharding"
-
xmlns:master-slave="http://shardingsphere.apache.org/schema/shardingsphere/orchestration/masterslave"
-
xmlns:reg="http://shardingsphere.apache.org/schema/shardingsphere/orchestration/reg"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
-
http://www.springframework.org/schema/beans/spring-beans.xsd
-
http://shardingsphere.apache.org/schema/shardingsphere/orchestration/reg
-
http://shardingsphere.apache.org/schema/shardingsphere/orchestration/reg/reg.xsd
-
http://shardingsphere.apache.org/schema/shardingsphere/orchestration/sharding
-
http://shardingsphere.apache.org/schema/shardingsphere/orchestration/sharding/sharding.xsd
-
http://shardingsphere.apache.org/schema/shardingsphere/orchestration/masterslave
-
http://shardingsphere.apache.org/schema/shardingsphere/orchestration/masterslave/master-slave.xsd">
-
- <util:properties id="instance-properties">
- <prop key="max-retries">3</prop>
- <prop key="operation-timeout-milliseconds">3000</prop>
- </util:properties>
- <orchestration:instance id="regCenter"
orchestration-type="registry_center,config_center,metadata_center"
instance-type="zookeeper" server-lists="localhost:2181"
namespace="orchestration-spring-namespace-demo"
- properties-ref="instance-properties" />
- <orchestration:data-source id="shardingDatabasesTablesDataSource"
data-source-ref="realShardingDatabasesTablesDataSource"
instance-ref="regCenter" overwrite="true" />
- <orchestration:slave-data-source id="masterSlaveDataSource"
data-source-ref="realMasterSlaveDataSource" instance-ref="regCenter"
overwrite="true" />
- <orchestration:data-source id="encryptDataSource"
data-source-ref="realEncryptDataSource" instance-ref="regCenter"
overwrite="true" />
-</beans>
-```
-
-## Configuration Item Explanation
-
-### Sharding
-
-Namespace:
http://shardingsphere.apache.org/schema/shardingsphere/sharding/sharding.xsd
-
-#### \<sharding:data-source />
-
-| *Name* | *Type* | *Description* |
-| ------------- | --------- | --------------------------- |
-| id | Attribute | Spring Bean Id |
-| sharding-rule | Tag | Sharding rule configuration |
-| properties (?) | Tag | Properties |
-
-#### \<sharding:sharding-rule />
-
-| *Name* | *Type* | *Description*
|
-| --------------------------------- | --------- |
------------------------------------------------------------ |
-| data-source-names | Attribute | Data source Bean list with
comma separating multiple Beans |
-| table-rules | Tag | Configuration objects of
table sharding rules |
-| binding-table-rules (?) | Tag | Binding table rule list
|
-| broadcast-table-rules (?) | Tag | Broadcast table rule list
|
-| default-data-source-name (?) | Attribute | Tables without sharding
rules will be located through default data source |
-| default-database-strategy-ref (?) | Attribute | Default database sharding
strategy, which corresponds to id of \<sharding:xxx-strategy>; default means
the database is not split |
-| default-table-strategy-ref (?) | Attribute | Default table sharding
strategy,which corresponds to id of \<sharding:xxx-strategy>; default means
the database is not split |
-| key-generate-strategy-ref (?) | Attribute | Default key generator
configuration, use user-defined ones or built-in ones, e.g. SNOWFLAKE/UUID.
Default key generator is
`org.apache.shardingsphere.core.keygen.generator.impl.SnowflakeKeyGenerator` |
-| encrypt-rule (?) | Tag | Encrypt rule
|
-
-#### \<sharding:table-rules />
-
-| *Name* | *Type* | *Description* |
-| -------------- | ------ | --------------------------------------------- |
-| table-rule (+) | Tag | Configuration objects of table sharding rules |
-
-#### \<sharding:table-rule />
-
-| *Name* | *Type* | *Description*
|
-| ----------------------------- | --------- |
------------------------------------------------------------ |
-| logic-table | Attribute | Name of logic table
|
-| actual-data-nodes (?) | Attribute | Describe data source names and
actual tables, delimiter as point, multiple data nodes separated with comma,
support inline expression. Absent means sharding databases only. Example:
ds${0..7}.tbl${0..7} |
-| database-strategy-ref (?) | Attribute | Databases sharding strategy, use
default databases sharding strategy if absent |
-| table-strategy-ref (?) | Attribute | Tables sharding strategy, use
default tables sharding strategy if absent |
-| key-generate-strategy-ref (?) | Attribute | Key generator, use default key
generator if absent. |
-
-#### \<sharding:binding-table-rules />
-
-| *Name* | *Type* | *Description* |
-| ---------------------- | ------ | -------------------------------- |
-| binding-table-rule (+) | Tag | Binding table rule configuration |
-
-#### \<sharding:binding-table-rule />
-
-| *Name* | *Type* | *Description*
|
-| ------------ | --------- |
------------------------------------------------------------ |
-| logic-tables | Attribute | Logic table name bound with rules; multiple
tables are separated by commas |
-
-#### \<sharding:broadcast-table-rules />
-
-| *Name* | *Type* | *Description* |
-| ------------------------ | ------ | --------------------- |
-| broadcast-table-rule (+) | Tag | Broadcast table rules |
-
-#### \<sharding:broadcast-table-rule />
-
-| *Name* | *Type* | *Description* |
-| -------------- | --------- | ------------- |
-| tableAttribute | Attribute | Name of table |
-
-#### \<sharding:standard-strategy />
-
-| *Name* | *Type* | *Description*
|
-| ----------------------- | --------- |
------------------------------------------------------------ |
-| id | Attribute | Spring Bean Id
|
-| sharding-column | Attribute | Sharding column name
|
-| precise-algorithm-ref | Attribute | Precise algorithm reference, applied
in `=` and `IN`; the class needs to implement `PreciseShardingAlgorithm`
interface |
-| range-algorithm-ref (?) | Attribute | Range algorithm reference, applied in
`BETWEEN`; the class needs to implement `RangeShardingAlgorithm` interface |
-
-#### \<sharding:complex-strategy />
-
-| *Name* | *Type* | *Description*
|
-| ---------------- | --------- |
------------------------------------------------------------ |
-| id | Attribute | Spring Bean Id
|
-| sharding-columns | Attribute | Sharding column name; multiple columns are
separated by commas |
-| algorithm-ref | Attribute | Complex sharding algorithm reference; the
class needs to implement `ComplexKeysShardingAlgorithm` interface |
-
-#### \<sharding:inline-strategy />
-
-| *Name* | *Type* | *Description*
|
-| -------------------- | --------- |
------------------------------------------------------------ |
-| id | Attribute | Spring Bean Id
|
-| sharding-column | Attribute | Sharding column name
|
-| algorithm-expression | Attribute | Sharding algorithm inline expression,
which needs to conform to groovy statements |
-
-#### \<sharding:hint-database-strategy />
-
-| *Name* | *Type* | *Description*
|
-| ------------- | --------- |
------------------------------------------------------------ |
-| id | Attribute | Spring Bean Id
|
-| algorithm-ref | Attribute | Hint sharding algorithm; the class needs to
implement `HintShardingAlgorithm` interface |
-
-#### \<sharding:none-strategy />
-
-| *Name* | *Type* | *Description* |
-| ------ | --------- | -------------- |
-| id | Attribute | Spring Bean Id |
-
-#### \<sharding:key-generate-strategy />
-
-| *Name* | *Type* | *Description*
|
-| --------- | --------- |
------------------------------------------------------------ |
-| column | Attribute | Auto-increment column name
|
-| type | Attribute | Auto-increment key generator `Type`; self-defined
generator or internal Type generator (SNOWFLAKE/UUID) can both be selected |
-| properties-ref | Attribute | The Property configuration reference of key
generators |
-
-#### Properties
-
-Property configuration that can include these properties of these key
generators.
-
-##### SNOWFLAKE
-
-| *Name* | *DataType* |
*Description*
|
-| --------------------------------------------------- | ---------- |
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-| worker.id (?) | long | The
unique id for working machine, the default value is `0`
|
-| max.tolerate.time.difference.milliseconds (?) | long | The max
tolerate time for different server's time difference in milliseconds, the
default value is `10`
|
-| max.vibration.offset (?) | int | The max
upper limit value of vibrate number, range `[0, 4096)`, the default value is
`1`. Notice: To use the generated value of this algorithm as sharding value, it
is recommended to configure this property. The algorithm generates key mod
`2^n` (`2^n` is usually the sharding amount of tables or databases) in
different milliseconds and the result is always `0` or `1`. To prevent the
above sharding problem, it is recomm [...]
-
-#### \<sharding:encrypt-rules />
-
-| *Name* | *Type* | *Description* |
-| -----------------| ------ | -------------- |
-| encrypt-rule (+) | Tag | Encrypt rule |
-
-#### \<sharding:encrypt-rule />
-
-| *Name* | *Type* | *Description*
|
-| ----------------------- | --------- |
------------------------------------------------------------ |
-| encrypt:encrypt-rule(?) | Tag | Encrypt rule
-
-#### \<sharding:properties />
-
-| *Name* | *Type* | *Description*
|
-| ---------------------------------- | --------- |
------------------------------------------------------------ |
-| sql.show (?) | Attribute | Show SQL or not; default
value: false |
-| executor.size (?) | Attribute | Executing thread number;
default value: CPU core number |
-| max.connections.size.per.query (?) | Attribute | The maximum connection
number that each physical database allocates to each query; default value: 1 |
-| check.table.metadata.enabled (?) | Attribute | Whether to check meta-data
consistency of sharding table when it initializes; default value: false |
-| query.with.cipher.column (?) | Attribute | When there is a
plainColumn, use cipherColumn or not to query, default value: true
|
-
-### Read-Write Split
-
-Namespace:
http://shardingsphere.apache.org/schema/shardingsphere/masterslave/master-slave.xsd
-
-#### \<master-slave:data-source />
-
-| *Name* | *Type* | *Description*
|
-| ----------------------- | --------- |
------------------------------------------------------------ |
-| id | Attribute | Spring Bean id
|
-| master-data-source-name | Attribute | Bean id of data source in master
database |
-| slave-data-source-names | Attribute | Bean id list of data source in slave
database; multiple Beans are separated by commas |
-| strategy-ref (?) | Attribute | Slave database load balance algorithm
reference; the class needs to implement `MasterSlaveLoadBalanceAlgorithm`
interface |
-| strategy-type (?) | Attribute | Load balance algorithm type of slave
database; optional value: ROUND_ROBIN and RANDOM; if there is
`load-balance-algorithm-class-name`, the configuration can be omitted |
-| config-map (?) | Tag | Users' self-defined configurations
|
-| properties (?) | Tag | Attribute configurations
|
-
-#### \<master-slave:properties />
-
-| *Name* | *Type* | *Description*
|
-| ---------------------------------- | --------- |
------------------------------------------------------------ |
-| sql.show (?) | Attribute | Show SQL or not; default
value: false |
-| executor.size (?) | Attribute | Executing thread number;
default value: CPU core number |
-| max.connections.size.per.query (?) | Attribute | The maximum connection
number that each physical database allocates to each query; default value: 1 |
-| check.table.metadata.enabled (?) | Attribute | Whether to check meta-data
consistency of sharding table when it initializes; default value: false |
-
-#### \<master-slave:load-balance-algorithm />
-4.0.0-RC2 version added
-
-| *Name* | *Type* | *Description*
|
-| ---------------------------------- | --------- |
------------------------------------------------------------ |
-| id | Attribute | Spring Bean Id
|
-| type | Attribute | Type of load balance
algorithm, 'RANDOM'或'ROUND_ROBIN', support custom extension|
-| properties-ref (?) | Attribute | Properties of load
balance algorithm |
-
-### data encryption
-
-Namespace:
http://shardingsphere.apache.org/schema/shardingsphere/encrypt/encrypt.xsd
-
-#### \<encrypt:data-source />
-
-| *Name* | *Type* | *Type* |
-| ----------------------- | --------- | --------------------------- |
-| id | Attribute | Spring Bean Id |
-| data-source-name | Attribute | Encrypt data source Bean Id |
-| properties (?) | Tag | Attribute configurations |
-
-#### \<encrypt:encrypt-algorithm />
-
-| *Name* | *Type* | *Description*
|
-| --------- | --------- |
--------------------------------------------------------------- |
-| id | Attribute | Names of Encrypt algorithm
|
-| type | Attribute | Types of Encrypt algorithm, including MD5/AES or
customize type |
-| properties-ref | Attribute | Attribute configurations
|
-
-#### \<encrypt:tables />
-
-| *Name* | *Type* | *Description*
|
-| ----------------------- | ----- |
--------------------------------------------------------- |
-| table(+) | Tag | Encrypt table configuration
|
-
-#### \<encrypt:table />
-
-| *Name* | *Type* | *Description*
|
-| ----------------------- | ------ |
---------------------------------------------------------|
-| column(+) | Tag | Encrypt column configuration
|
-
-#### \<encrypt:column />
-
-| *Name* | *Type* | *Description*
|
-| ----------------------- | --------- |
---------------------------------------------------------------------------------------------------
|
-| logic-column | Attribute | Logic column name
|
-| plain-column | Attribute | Plain column name
|
-| cipher-column | Attribute | Cipher column name
|
-| assisted-query-columns | Attribute | AssistedColumns for query,when use
QueryAssistedEncryptAlgorithm, it can help query encrypted data|
-
-#### \<encrypt:properties />
-
-| *Name* | *Type* | *Description*
|
-| ---------------------------------- | --------- |
------------------------------------------------------------ |
-| sql.show (?) | Attribute | Show SQL or not; default
value: false |
-| query.with.cipher.column (?) | Attribute | When there is a
plainColumn, use cipherColumn or not to query, default value: true
|
-
-### Data Sharding + Orchestration
-
-Namespace:
http://shardingsphere.apache.org/schema/shardingsphere/orchestration/orchestration.xsd
-
-#### \<orchestration:master-slave-data-source />
-
-| *Name* | *Type* | *Description*
|
-| ------------------- | --------- |
------------------------------------------------------------ |
-| id | Attribute | ID
|
-| data-source-ref (?) | Attribute | Orchestrated database id
|
-| instance-ref | Attribute | The id of orchestration instance
|
-| overwrite | Attribute | Whether to overwrite local configurations
with config center configurations; if it can, each initialization should refer
to local configurations; default means not to overwrite |
-
-### Read-Write Split + Orchestration
-
-Namespace:
http://shardingsphere.apache.org/schema/shardingsphere/orchestration/orchestration.xsd
-
-#### \<orchestration:sharding-data-source />
-
-| *Name* | *Type* | *Description*
|
-| ------------------- | --------- |
----------------------------------------------------------- |
-| id | Attribute | ID
|
-| data-source-ref (?) | Attribute | The id of data source to be orchestrated
|
-| instance-ref | Attribute | The id of orchestration instance
|
-| overwrite | Attribute | Use local configuration to overwrite
config center or not |
-
-### data encryption + Orchestration
-
-Namespace:
http://shardingsphere.apache.org/schema/shardingsphere/orchestration/orchestration.xsd
-
-#### \<orchestration:encrypt-data-source />
-
-| *Name* | *Type* | *Description*
|
-| ------------------- | --------- |
----------------------------------------------------------- |
-| id | Attribute | ID
|
-| data-source-ref (?) | Attribute | The id of data source to be orchestrated
|
-| instance-ref | Attribute | The id of orchestration instance
|
-| overwrite | Attribute | Use local configuration to overwrite
config center or not |
-
-
-### Orchestration instance
-
-Namespace:
http://shardingsphere.apache.org/schema/shardingsphere/orchestration/orchestration.xsd
-
-#### \<orchestration:instance />
-
-| *Name* | *Type* | *Description*
|
-| ---------------------------------- | --------- |
-------------------------------------------------------------------------------
|
-| id | Attribute | Spring Bean Id of center
|
-| instance-type | Attribute | Center instance type.
Example:zookeeper |
-| orchestration-type | Attribute | The type of orchestration
center: config_center or registry_center or metadata_center |
-| server-lists | Attribute | Center servers list,
multiple split as comma. Example: host1:2181,host2:2181 |
-| namespace (?) | Attribute | Namespace of center
|
-| properties-ref (?) | Attribute | Other customize
properties of registry center |
diff --git
a/docs/document/content/user-manual/shardingsphere-jdbc/configuration/spring-boot-starter/_index.cn.md
b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/spring-boot-starter/_index.cn.md
new file mode 100644
index 0000000..2598a76
--- /dev/null
+++
b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/spring-boot-starter/_index.cn.md
@@ -0,0 +1,74 @@
++++
+title = "Spring Boot Start 配置"
+weight = 3
++++
+
+## 简介
+
+ShardingSphere-JDBC 提供官方的 Spring Boot Starter,使开发者可以非常便捷的整合
ShardingSphere-JDBC 和 Spring Boot。
+
+## Spring Boot Start 配置项
+
+### 数据源配置
+
+#### 配置示例
+
+```properties
+spring.shardingsphere.datasource.names=ds0,ds1
+
+spring.shardingsphere.datasource.ds0.type=org.apache.commons.dbcp2.BasicDataSource
+spring.shardingsphere.datasource.ds0.driver-class-name=com.mysql.jdbc.Driver
+spring.shardingsphere.datasource.ds0.url=jdbc:mysql://localhost:3306/ds0
+spring.shardingsphere.datasource.ds0.username=root
+spring.shardingsphere.datasource.ds0.password=root
+
+spring.shardingsphere.datasource.ds1.type=org.apache.commons.dbcp2.BasicDataSource
+spring.shardingsphere.datasource.ds1.driver-class-name=com.mysql.jdbc.Driver
+spring.shardingsphere.datasource.ds1.url=jdbc:mysql://localhost:3306/ds1
+spring.shardingsphere.datasource.ds1.username=root
+spring.shardingsphere.datasource.ds1.password=root
+```
+
+#### 配置项说明
+
+```properties
+spring.shardingsphere.datasource.names= # 数据源名称,多数据源以逗号分隔
+
+spring.shardingsphere.datasource.<datasource_name>.type= # 数据库连接池类名称
+spring.shardingsphere.datasource.<datasource_name>.driver-class-name= # 数据库驱动类名
+spring.shardingsphere.datasource.<datasource_name>.url= # 数据库 URL 连接
+spring.shardingsphere.datasource.<datasource_name>.username= # 数据库用户名
+spring.shardingsphere.datasource.<datasource_name>.password= # 数据库密码
+spring.shardingsphere.datasource.<data-source-name>.xxx= # 数据库连接池的其它属性
+```
+
+### 规则配置
+
+#### 配置示例
+
+```properties
+spring.shardingsphere.rules.sharding.xxx=xxx
+```
+
+#### 配置项说明
+
+```properties
+spring.shardingsphere.rules.<rule-type>.xxx= # 规则配置
+ # ... 具体的规则配置
+```
+
+更多详细配置请参见具体的规则配置部分。
+
+### 属性配置
+
+#### 配置示例
+
+```properties
+spring.shardingsphere.props.xxx.xxx=xxx
+```
+
+#### 配置项说明
+
+```properties
+spring.shardingsphere.props.xxx.xxx= # 具体的属性配置
+```
diff --git
a/docs/document/content/user-manual/shardingsphere-jdbc/configuration/spring-boot-starter/_index.en.md
b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/spring-boot-starter/_index.en.md
new file mode 100644
index 0000000..9f9b6d9
--- /dev/null
+++
b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/spring-boot-starter/_index.en.md
@@ -0,0 +1,74 @@
++++
+title = "Spring Boot Starter Configuration"
+weight = 3
++++
+
+## Introduction
+
+ShardingSphere-JDBC provides official Spring Boot Starter to make convenient
for developers to integrate ShardingSphere-JDBC and Spring Boot.
+
+## Spring Boot Start Configuration Item
+
+### Data Source Configuration
+
+#### Configuration Example
+
+```properties
+spring.shardingsphere.datasource.names=ds0,ds1
+
+spring.shardingsphere.datasource.ds0.type=org.apache.commons.dbcp2.BasicDataSource
+spring.shardingsphere.datasource.ds0.driver-class-name=com.mysql.jdbc.Driver
+spring.shardingsphere.datasource.ds0.url=jdbc:mysql://localhost:3306/ds0
+spring.shardingsphere.datasource.ds0.username=root
+spring.shardingsphere.datasource.ds0.password=root
+
+spring.shardingsphere.datasource.ds1.type=org.apache.commons.dbcp2.BasicDataSource
+spring.shardingsphere.datasource.ds1.driver-class-name=com.mysql.jdbc.Driver
+spring.shardingsphere.datasource.ds1.url=jdbc:mysql://localhost:3306/ds1
+spring.shardingsphere.datasource.ds1.username=root
+spring.shardingsphere.datasource.ds1.password=root
+```
+
+#### Configuration Item Explanation
+
+```properties
+spring.shardingsphere.datasource.names= # Data source name, multiple data
sources are separated by commas
+
+spring.shardingsphere.datasource.<datasource_name>.type= # Database connection
pool type name
+spring.shardingsphere.datasource.<datasource_name>.driver-class-name= #
Database driver class name
+spring.shardingsphere.datasource.<datasource_name>.url= # Database URL
connection
+spring.shardingsphere.datasource.<datasource_name>.username= # Database
username
+spring.shardingsphere.datasource.<datasource_name>.password= # Database
password
+spring.shardingsphere.datasource.<data-source-name>.xxx= # Other properties of
database connection pool
+```
+
+### Rule Configuration
+
+#### Configuration Example
+
+```properties
+spring.shardingsphere.rules.sharding.xxx=xxx
+```
+
+#### Configuration Item Explanation
+
+```properties
+spring.shardingsphere.rules.<rule-type>.xxx= # rule configurations
+ # ... Specific rule configurations
+```
+
+Please refer to specific rule configuration for more details.
+
+### Properties Configuration
+
+#### Configuration Example
+
+```properties
+spring.shardingsphere.props.xxx.xxx=xxx
+```
+
+#### Configuration Item Explanation
+
+```properties
+spring.shardingsphere.props.xxx.xxx= # Properties key and value
+```
diff --git
a/docs/document/content/user-manual/shardingsphere-jdbc/configuration/config-spring-boot.cn.md
b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/spring-boot-starter/config-spring-boot.cn.md
similarity index 100%
rename from
docs/document/content/user-manual/shardingsphere-jdbc/configuration/config-spring-boot.cn.md
rename to
docs/document/content/user-manual/shardingsphere-jdbc/configuration/spring-boot-starter/config-spring-boot.cn.md
diff --git
a/docs/document/content/user-manual/shardingsphere-jdbc/configuration/config-spring-boot.en.md
b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/spring-boot-starter/config-spring-boot.en.md
similarity index 100%
rename from
docs/document/content/user-manual/shardingsphere-jdbc/configuration/config-spring-boot.en.md
rename to
docs/document/content/user-manual/shardingsphere-jdbc/configuration/spring-boot-starter/config-spring-boot.en.md
diff --git
a/docs/document/content/user-manual/shardingsphere-jdbc/configuration/yaml/_index.cn.md
b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/yaml/_index.cn.md
index dbf1b91..2c9d67e 100644
---
a/docs/document/content/user-manual/shardingsphere-jdbc/configuration/yaml/_index.cn.md
+++
b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/yaml/_index.cn.md
@@ -55,7 +55,7 @@ try (
}
```
-## YAML 配置
+## YAML 配置项
### 数据源配置
@@ -65,7 +65,7 @@ try (
#### 单数据源配置
-配置示例:
+##### 配置示例
```yaml
dataSource: !!org.apache.commons.dbcp2.BasicDataSource
@@ -75,7 +75,7 @@ dataSource: !!org.apache.commons.dbcp2.BasicDataSource
password: root
```
-配置项说明:
+##### 配置项说明
```yaml
dataSource: # <!!数据库连接池实现类> `!!`表示实例化该类
diff --git
a/docs/document/content/user-manual/shardingsphere-jdbc/configuration/yaml/_index.en.md
b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/yaml/_index.en.md
index 3677fca..8b4428d 100644
---
a/docs/document/content/user-manual/shardingsphere-jdbc/configuration/yaml/_index.en.md
+++
b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/yaml/_index.en.md
@@ -57,7 +57,7 @@ try (
}
```
-## YAML Configuration
+## YAML Configuration Item
### Data Source Configuration
diff --git
a/docs/document/content/user-manual/shardingsphere-jdbc/configuration/yaml/config-yaml.cn.md
b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/yaml/config-yaml.cn.md
index 5170666..9dbd337 100644
---
a/docs/document/content/user-manual/shardingsphere-jdbc/configuration/yaml/config-yaml.cn.md
+++
b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/yaml/config-yaml.cn.md
@@ -9,12 +9,12 @@ weight = 20
```yaml
dataSources:
- ds0: !!org.apache.commons.dbcp.BasicDataSource
+ ds0: !!org.apache.commons.dbcp2.BasicDataSource
driverClassName: com.mysql.jdbc.Driver
url: jdbc:mysql://localhost:3306/ds0
username: root
password:
- ds1: !!org.apache.commons.dbcp.BasicDataSource
+ ds1: !!org.apache.commons.dbcp2.BasicDataSource
driverClassName: com.mysql.jdbc.Driver
url: jdbc:mysql://localhost:3306/ds1
username: root
diff --git
a/docs/document/content/user-manual/shardingsphere-jdbc/configuration/yaml/config-yaml.en.md
b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/yaml/config-yaml.en.md
index da7a5f6..79f0b2b 100644
---
a/docs/document/content/user-manual/shardingsphere-jdbc/configuration/yaml/config-yaml.en.md
+++
b/docs/document/content/user-manual/shardingsphere-jdbc/configuration/yaml/config-yaml.en.md
@@ -9,12 +9,12 @@ weight = 20
```yaml
dataSources:
- ds0: !!org.apache.commons.dbcp.BasicDataSource
+ ds0: !!org.apache.commons.dbcp2.BasicDataSource
driverClassName: com.mysql.jdbc.Driver
url: jdbc:mysql://localhost:3306/ds0
username: root
password:
- ds1: !!org.apache.commons.dbcp.BasicDataSource
+ ds1: !!org.apache.commons.dbcp2.BasicDataSource
driverClassName: com.mysql.jdbc.Driver
url: jdbc:mysql://localhost:3306/ds1
username: root
@@ -65,17 +65,17 @@ props:
```yaml
dataSources:
- ds_master: !!org.apache.commons.dbcp.BasicDataSource
+ ds_master: !!org.apache.commons.dbcp2.BasicDataSource
driverClassName: com.mysql.jdbc.Driver
url: jdbc:mysql://localhost:3306/ds_master
username: root
password:
- ds_slave0: !!org.apache.commons.dbcp.BasicDataSource
+ ds_slave0: !!org.apache.commons.dbcp2.BasicDataSource
driverClassName: com.mysql.jdbc.Driver
url: jdbc:mysql://localhost:3306/ds_slave0
username: root
password:
- ds_slave1: !!org.apache.commons.dbcp.BasicDataSource
+ ds_slave1: !!org.apache.commons.dbcp2.BasicDataSource
driverClassName: com.mysql.jdbc.Driver
url: jdbc:mysql://localhost:3306/ds_slave1
username: root