You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by ji...@apache.org on 2022/11/30 10:03:08 UTC
[shardingsphere] branch master updated: Refactor spi-based-sharding-algorithm-example with ShardingSphereDriver (#22524)
This is an automated email from the ASF dual-hosted git repository.
jianglongtao 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 0934e338dd5 Refactor spi-based-sharding-algorithm-example with ShardingSphereDriver (#22524)
0934e338dd5 is described below
commit 0934e338dd549d4325650597355b67d27dfe77d4
Author: ChenJiaHao <37...@users.noreply.github.com>
AuthorDate: Wed Nov 30 18:02:59 2022 +0800
Refactor spi-based-sharding-algorithm-example with ShardingSphereDriver (#22524)
* Refactor spi-based-sharding-algorithm-example with ShardingSphereDriver
* Clear password in config file
* Fix
* Fix
---
.../pom.xml | 2 +-
...dDatabaseStandardShardingAlgorithmFixture.java} | 4 +-
...e.shardingsphere.sharding.spi.ShardingAlgorithm | 2 +-
.../application-sharding-auto-tables.properties | 40 +---------
...pplication-sharding-databases-tables.properties | 51 +------------
.../application-sharding-databases.properties | 34 +--------
.../application-sharding-tables.properties | 41 +----------
.../src/main/resources/sharding-auto-tables.yaml | 67 +++++++++++++++++
.../main/resources/sharding-databases-tables.yaml | 86 ++++++++++++++++++++++
.../src/main/resources/sharding-databases.yaml | 63 ++++++++++++++++
.../src/main/resources/sharding-tables.yaml | 74 +++++++++++++++++++
.../pom.xml | 2 +-
...dDatabaseStandardShardingAlgorithmFixture.java} | 4 +-
...e.shardingsphere.sharding.spi.ShardingAlgorithm | 2 +-
.../application-sharding-auto-tables.properties | 40 +---------
...pplication-sharding-databases-tables.properties | 43 +----------
.../application-sharding-databases.properties | 34 +--------
.../application-sharding-tables.properties | 33 +--------
.../src/main/resources/sharding-auto-tables.yaml | 67 +++++++++++++++++
.../main/resources/sharding-databases-tables.yaml | 75 +++++++++++++++++++
.../src/main/resources/sharding-databases.yaml | 63 ++++++++++++++++
.../src/main/resources/sharding-tables.yaml | 63 ++++++++++++++++
.../pom.xml | 2 +-
...dDatabaseStandardShardingAlgorithmFixture.java} | 4 +-
.../application-sharding-databases-tables.xml | 68 ++---------------
.../META-INF/application-sharding-databases.xml | 51 ++-----------
.../META-INF/application-sharding-tables.xml | 50 ++-----------
...e.shardingsphere.sharding.spi.ShardingAlgorithm | 2 +-
.../main/resources/sharding-databases-tables.yaml | 86 ++++++++++++++++++++++
.../src/main/resources/sharding-databases.yaml | 68 +++++++++++++++++
.../src/main/resources/sharding-tables.yaml | 74 +++++++++++++++++++
.../pom.xml | 2 +-
...dDatabaseStandardShardingAlgorithmFixture.java} | 4 +-
.../application-sharding-databases-tables.xml | 54 ++------------
.../META-INF/application-sharding-databases.xml | 54 ++------------
.../META-INF/application-sharding-tables.xml | 61 ++-------------
...e.shardingsphere.sharding.spi.ShardingAlgorithm | 2 +-
.../main/resources/sharding-databases-tables.yaml | 65 ++++++++++++++++
.../src/main/resources/sharding-databases.yaml | 65 ++++++++++++++++
.../src/main/resources/sharding-tables.yaml | 67 +++++++++++++++++
40 files changed, 1048 insertions(+), 621 deletions(-)
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-jpa-example/pom.xml b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-jpa-example/pom.xml
index 9d8655342af..b69a9518276 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-jpa-example/pom.xml
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-jpa-example/pom.xml
@@ -36,7 +36,7 @@
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-jdbc-core-spring-boot-starter</artifactId>
+ <artifactId>shardingsphere-jdbc-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-jpa-example/src/main/java/org/apache/shardingsphere/example/sharding/spring/boot/jpa/fixture/SPIBasedDatasourceStandardShardingAlgorithmFixture.java b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/ [...]
similarity index 92%
rename from examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-jpa-example/src/main/java/org/apache/shardingsphere/example/sharding/spring/boot/jpa/fixture/SPIBasedDatasourceStandardShardingAlgorithmFixture.java
rename to examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-jpa-example/src/main/java/org/apache/shardingsphere/example/sharding/spring/boot/jpa/fixture/SPIBasedDatabaseStandardShardingAlgorithmFixture.java
index 2b4360bb52e..0d40f3daba9 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-jpa-example/src/main/java/org/apache/shardingsphere/example/sharding/spring/boot/jpa/fixture/SPIBasedDatasourceStandardShardingAlgorithmFixture.java
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-jpa-example/src/main/java/org/apache/shardingsphere/example/sharding/spring/boot/jpa/fixture/SPIBasedDatabaseStandardShardingAlgorithmFixture.java
@@ -24,7 +24,7 @@ import java.util.Collection;
import java.util.Properties;
@Getter
-public final class SPIBasedDatasourceStandardShardingAlgorithmFixture implements StandardShardingAlgorithm<Integer> {
+public final class SPIBasedDatabaseStandardShardingAlgorithmFixture implements StandardShardingAlgorithm<Integer> {
private Properties props;
@@ -54,6 +54,6 @@ public final class SPIBasedDatasourceStandardShardingAlgorithmFixture implements
@Override
public String getType() {
- return "DATASOURCE_SPI_BASED";
+ return "DATABASE_SPI_BASED";
}
}
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-jpa-example/src/main/resources/META-INF/services/org.apache.shardingsphere.sharding.spi.ShardingAlgorithm b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-jpa-example/ [...]
index 696160233cd..1355f218ff1 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-jpa-example/src/main/resources/META-INF/services/org.apache.shardingsphere.sharding.spi.ShardingAlgorithm
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-jpa-example/src/main/resources/META-INF/services/org.apache.shardingsphere.sharding.spi.ShardingAlgorithm
@@ -15,5 +15,5 @@
# limitations under the License.
#
-org.apache.shardingsphere.example.sharding.spring.boot.jpa.fixture.SPIBasedDatasourceStandardShardingAlgorithmFixture
+org.apache.shardingsphere.example.sharding.spring.boot.jpa.fixture.SPIBasedDatabaseStandardShardingAlgorithmFixture
org.apache.shardingsphere.example.sharding.spring.boot.jpa.fixture.SPIBasedOrderStandardShardingAlgorithmFixture
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-jpa-example/src/main/resources/application-sharding-auto-tables.properties b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-jpa-example/src/main/resources/application- [...]
index 5a420632c1b..0e64cb7cbf7 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-jpa-example/src/main/resources/application-sharding-auto-tables.properties
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-jpa-example/src/main/resources/application-sharding-auto-tables.properties
@@ -15,41 +15,5 @@
# limitations under the License.
#
-spring.shardingsphere.datasource.names=ds-0,ds-1
-
-spring.shardingsphere.datasource.ds-0.jdbc-url=jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
-spring.shardingsphere.datasource.ds-0.type=com.zaxxer.hikari.HikariDataSource
-spring.shardingsphere.datasource.ds-0.driver-class-name=com.mysql.jdbc.Driver
-spring.shardingsphere.datasource.ds-0.username=root
-spring.shardingsphere.datasource.ds-0.password=
-
-spring.shardingsphere.datasource.ds-1.jdbc-url=jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
-spring.shardingsphere.datasource.ds-1.type=com.zaxxer.hikari.HikariDataSource
-spring.shardingsphere.datasource.ds-1.driver-class-name=com.mysql.jdbc.Driver
-spring.shardingsphere.datasource.ds-1.username=root
-spring.shardingsphere.datasource.ds-1.password=
-
-spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-column=user_id
-spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-algorithm-name=database-inline
-spring.shardingsphere.rules.sharding.binding-tables[0]=t_order,t_order_item
-
-spring.shardingsphere.rules.sharding.autotables.t_order.actual-datasources=ds-${0..1}
-
-spring.shardingsphere.rules.sharding.auto-tables.t_order.sharding-strategy.standard.sharding-column=order_id
-spring.shardingsphere.rules.sharding.auto-tables.t_order.sharding-strategy.standard.sharding-algorithm-name=auto-mod
-
-spring.shardingsphere.rules.sharding.auto-tables.t_order.key-generate-strategy.column=order_id
-spring.shardingsphere.rules.sharding.auto-tables.t_order.key-generate-strategy.key-generator-name=snowflake
-
-spring.shardingsphere.rules.sharding.auto-tables.t_order_item.actual-datasources=ds-${0..1}
-
-spring.shardingsphere.rules.sharding.auto-tables.t_order_item.sharding-strategy.standard.sharding-column=order_item_id
-spring.shardingsphere.rules.sharding.auto-tables.t_order_item.sharding-strategy.standard.sharding-algorithm-name=auto-mod
-
-spring.shardingsphere.rules.sharding.auto-tables.t_order_item.key-generate-strategy.column=order_item_id
-spring.shardingsphere.rules.sharding.auto-tables.t_order_item.key-generate-strategy.key-generator-name=snowflake
-
-spring.shardingsphere.rules.sharding.sharding-algorithms.auto-mod.type=mod
-spring.shardingsphere.rules.sharding.sharding-algorithms.auto-mod.props.sharding-count=4
-
-spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE
+spring.datasource.driver-class-name=org.apache.shardingsphere.driver.ShardingSphereDriver
+spring.datasource.url=jdbc:shardingsphere:classpath:sharding-auto-tables.yaml
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-jpa-example/src/main/resources/application-sharding-databases-tables.properties b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-jpa-example/src/main/resources/applica [...]
index 398621ae1c9..12969865b87 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-jpa-example/src/main/resources/application-sharding-databases-tables.properties
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-jpa-example/src/main/resources/application-sharding-databases-tables.properties
@@ -15,52 +15,5 @@
# limitations under the License.
#
-spring.shardingsphere.datasource.names=ds-0,ds-1
-
-spring.shardingsphere.datasource.ds-0.jdbc-url=jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
-spring.shardingsphere.datasource.ds-0.type=com.zaxxer.hikari.HikariDataSource
-spring.shardingsphere.datasource.ds-0.driver-class-name=com.mysql.jdbc.Driver
-spring.shardingsphere.datasource.ds-0.username=root
-spring.shardingsphere.datasource.ds-0.password=
-spring.shardingsphere.datasource.ds-0.max-active=16
-
-spring.shardingsphere.datasource.ds-1.jdbc-url=jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
-spring.shardingsphere.datasource.ds-1.type=com.zaxxer.hikari.HikariDataSource
-spring.shardingsphere.datasource.ds-1.driver-class-name=com.mysql.jdbc.Driver
-spring.shardingsphere.datasource.ds-1.username=root
-spring.shardingsphere.datasource.ds-1.password=
-spring.shardingsphere.datasource.ds-1.max-active=16
-
-spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-column=user_id
-spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-algorithm-name=datasource-spi-based
-spring.shardingsphere.rules.sharding.binding-tables[0]=t_order,t_order_item
-spring.shardingsphere.rules.sharding.broadcast-tables=t_address
-
-spring.shardingsphere.rules.sharding.tables.t_order.actual-data-nodes=ds-$->{0..1}.t_order_$->{0..1}
-spring.shardingsphere.rules.sharding.tables.t_order.table-strategy.standard.sharding-column=order_id
-spring.shardingsphere.rules.sharding.tables.t_order.table-strategy.standard.sharding-algorithm-name=t-order-spi-based
-
-spring.shardingsphere.rules.sharding.tables.t_order.key-generate-strategy.column=order_id
-spring.shardingsphere.rules.sharding.tables.t_order.key-generate-strategy.key-generator-name=snowflake
-
-spring.shardingsphere.rules.sharding.tables.t_order_item.actual-data-nodes=ds-$->{0..1}.t_order_item_$->{0..1}
-spring.shardingsphere.rules.sharding.tables.t_order_item.table-strategy.standard.sharding-column=order_id
-spring.shardingsphere.rules.sharding.tables.t_order_item.table-strategy.standard.sharding-algorithm-name=t-order-item-spi-based
-
-spring.shardingsphere.rules.sharding.tables.t_order_item.key-generate-strategy.column=order_item_id
-spring.shardingsphere.rules.sharding.tables.t_order_item.key-generate-strategy.key-generator-name=snowflake
-
-spring.shardingsphere.rules.sharding.tables.t_account.actual-data-nodes=ds-$->{0..1}.t_account_$->{0..1}
-spring.shardingsphere.rules.sharding.tables.t_account.table-strategy.standard.sharding-algorithm-name=t-account-spi-based
-
-spring.shardingsphere.rules.sharding.tables.t_account.key-generate-strategy.column=account_id
-spring.shardingsphere.rules.sharding.tables.t_account.key-generate-strategy.key-generator-name=snowflake
-
-spring.shardingsphere.rules.sharding.default-sharding-column=account_id
-
-spring.shardingsphere.rules.sharding.sharding-algorithms.datasource-spi-based.type=DATASOURCE_SPI_BASED
-spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-spi-based.type=T_ORDER_SPI_BASED
-spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-item-spi-based.type=T_ORDER_SPI_BASED
-spring.shardingsphere.rules.sharding.sharding-algorithms.t-account-spi-based.type=T_ORDER_SPI_BASED
-
-spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE
+spring.datasource.driver-class-name=org.apache.shardingsphere.driver.ShardingSphereDriver
+spring.datasource.url=jdbc:shardingsphere:classpath:sharding-databases-tables.yaml
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-jpa-example/src/main/resources/application-sharding-databases.properties b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-jpa-example/src/main/resources/application-sh [...]
index d862b38b2f5..c3a61cc66a5 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-jpa-example/src/main/resources/application-sharding-databases.properties
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-jpa-example/src/main/resources/application-sharding-databases.properties
@@ -15,35 +15,5 @@
# limitations under the License.
#
-spring.shardingsphere.datasource.names=ds-0,ds-1
-
-spring.shardingsphere.datasource.ds-0.jdbc-url=jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
-spring.shardingsphere.datasource.ds-0.type=com.zaxxer.hikari.HikariDataSource
-spring.shardingsphere.datasource.ds-0.driver-class-name=com.mysql.jdbc.Driver
-spring.shardingsphere.datasource.ds-0.username=root
-spring.shardingsphere.datasource.ds-0.password=
-
-spring.shardingsphere.datasource.ds-1.jdbc-url=jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
-spring.shardingsphere.datasource.ds-1.type=com.zaxxer.hikari.HikariDataSource
-spring.shardingsphere.datasource.ds-1.driver-class-name=com.mysql.jdbc.Driver
-spring.shardingsphere.datasource.ds-1.username=root
-spring.shardingsphere.datasource.ds-1.password=
-
-spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-column=user_id
-spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-algorithm-name=datasource-spi-based
-spring.shardingsphere.rules.sharding.binding-tables[0]=t_order,t_order_item
-spring.shardingsphere.rules.sharding.broadcast-tables=t_address
-
-spring.shardingsphere.rules.sharding.tables.t_order.actual-data-nodes=ds-$->{0..1}.t_order
-
-spring.shardingsphere.rules.sharding.tables.t_order.key-generate-strategy.column=order_id
-spring.shardingsphere.rules.sharding.tables.t_order.key-generate-strategy.key-generator-name=snowflake
-
-spring.shardingsphere.rules.sharding.tables.t_order_item.actual-data-nodes=ds-$->{0..1}.t_order_item
-
-spring.shardingsphere.rules.sharding.tables.t_order_item.key-generate-strategy.column=order_item_id
-spring.shardingsphere.rules.sharding.tables.t_order_item.key-generate-strategy.key-generator-name=snowflake
-
-spring.shardingsphere.rules.sharding.sharding-algorithms.datasource-spi-based.type=DATASOURCE_SPI_BASED
-
-spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE
+spring.datasource.driver-class-name=org.apache.shardingsphere.driver.ShardingSphereDriver
+spring.datasource.url=jdbc:shardingsphere:classpath:sharding-databases.yaml
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-jpa-example/src/main/resources/application-sharding-tables.properties b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-jpa-example/src/main/resources/application-shard [...]
index 3a8b23581e9..4b6a1fe81b0 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-jpa-example/src/main/resources/application-sharding-tables.properties
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-jpa-example/src/main/resources/application-sharding-tables.properties
@@ -15,42 +15,5 @@
# limitations under the License.
#
-spring.shardingsphere.datasource.names=ds
-
-spring.shardingsphere.datasource.ds.type=com.zaxxer.hikari.HikariDataSource
-spring.shardingsphere.datasource.ds.driver-class-name=com.mysql.jdbc.Driver
-spring.shardingsphere.datasource.ds.jdbc-url=jdbc:mysql://localhost:3306/demo_ds?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
-spring.shardingsphere.datasource.ds.username=root
-spring.shardingsphere.datasource.ds.password=
-spring.shardingsphere.datasource.ds.max-active=16
-
-spring.shardingsphere.rules.sharding.tables.t_order.actual-data-nodes=ds.t_order_$->{0..1}
-spring.shardingsphere.rules.sharding.tables.t_order.table-strategy.standard.sharding-column=order_id
-spring.shardingsphere.rules.sharding.tables.t_order.table-strategy.standard.sharding-algorithm-name=t-order-spi-based
-
-spring.shardingsphere.rules.sharding.tables.t_order.key-generate-strategy.column=order_id
-spring.shardingsphere.rules.sharding.tables.t_order.key-generate-strategy.key-generator-name=snowflake
-
-spring.shardingsphere.rules.sharding.tables.t_order_item.actual-data-nodes=ds.t_order_item_$->{0..1}
-spring.shardingsphere.rules.sharding.tables.t_order_item.table-strategy.standard.sharding-column=order_id
-spring.shardingsphere.rules.sharding.tables.t_order_item.table-strategy.standard.sharding-algorithm-name=t-order-item-spi-based
-
-spring.shardingsphere.rules.sharding.tables.t_order_item.key-generate-strategy.column=order_item_id
-spring.shardingsphere.rules.sharding.tables.t_order_item.key-generate-strategy.key-generator-name=snowflake
-
-spring.shardingsphere.rules.sharding.tables.t_account.actual-data-nodes=ds.t_account_$->{0..1}
-spring.shardingsphere.rules.sharding.tables.t_account.table-strategy.standard.sharding-algorithm-name=t-account-spi-based
-
-spring.shardingsphere.rules.sharding.default-sharding-column=account_id
-
-spring.shardingsphere.rules.sharding.tables.t_account.key-generate-strategy.column=account_id
-spring.shardingsphere.rules.sharding.tables.t_account.key-generate-strategy.key-generator-name=snowflake
-
-spring.shardingsphere.rules.sharding.binding-tables[0]=t_order,t_order_item
-spring.shardingsphere.rules.sharding.broadcast-tables=t_address
-
-spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-spi-based.type=T_ORDER_SPI_BASED
-spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-item-spi-based.type=T_ORDER_SPI_BASED
-spring.shardingsphere.rules.sharding.sharding-algorithms.t-account-spi-based.type=T_ORDER_SPI_BASED
-
-spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE
+spring.datasource.driver-class-name=org.apache.shardingsphere.driver.ShardingSphereDriver
+spring.datasource.url=jdbc:shardingsphere:classpath:sharding-tables.yaml
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-jpa-example/src/main/resources/sharding-auto-tables.yaml b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-jpa-example/src/main/resources/sharding-auto-tables.yaml
new file mode 100644
index 00000000000..cd7cd1d7e45
--- /dev/null
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-jpa-example/src/main/resources/sharding-auto-tables.yaml
@@ -0,0 +1,67 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+dataSources:
+ ds_0:
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ jdbcUrl: jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF_8
+ username: root
+ password:
+ ds_1:
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ jdbcUrl: jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+ username: root
+ password:
+
+rules:
+- !SHARDING
+ autoTables:
+ t_order:
+ actualDataSources: ds_${0..1}
+ shardingStrategy:
+ standard:
+ shardingColumn: order_id
+ shardingAlgorithmName: auto_mod
+ keyGenerateStrategy:
+ column: order_id
+ keyGeneratorName: snowflake
+ t_order_item:
+ actualDataSources: ds_${0..1}
+ shardingStrategy:
+ standard:
+ shardingColumn: order_item_id
+ shardingAlgorithmName: auto_mod
+ keyGenerateStrategy:
+ column: order_item_id
+ keyGeneratorName: snowflake
+ bindingTables:
+ - t_order,t_order_item
+
+ shardingAlgorithms:
+ auto_mod:
+ type: mod
+ props:
+ sharding-count: 4
+
+ keyGenerators:
+ snowflake:
+ type: SNOWFLAKE
+
+props:
+ spl-show: true
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-jpa-example/src/main/resources/sharding-databases-tables.yaml b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-jpa-example/src/main/resources/sharding-databases-tables.yaml
new file mode 100644
index 00000000000..83842be5142
--- /dev/null
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-jpa-example/src/main/resources/sharding-databases-tables.yaml
@@ -0,0 +1,86 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+dataSources:
+ ds_0:
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ jdbcUrl: jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+ username: root
+ password:
+ ds_1:
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ jdbcUrl: jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+ username: root
+ password:
+
+rules:
+- !SHARDING
+ tables:
+ t_order:
+ actualDataNodes: ds_${0..1}.t_order_$->{0..1}
+ tableStrategy:
+ standard:
+ shardingColumn: order_id
+ shardingAlgorithmName: t_order_spi_based
+ keyGenerateStrategy:
+ column: order_id
+ keyGeneratorName: snowflake
+ t_order_item:
+ actualDataNodes: ds_${0..1}.t_order_item_$->{0..1}
+ tableStrategy:
+ standard:
+ shardingColumn: order_id
+ shardingAlgorithmName: t_order_item_spi_based
+ keyGenerateStrategy:
+ column: order_item_id
+ keyGeneratorName: snowflake
+ t_account:
+ actualDataNodes: ds_${0..1}.t_account_$->{0..1}
+ tableStrategy:
+ standard:
+ shardingAlgorithmName: t_account_spi_based
+ keyGenerateStrategy:
+ column: account_id
+ keyGeneratorName: snowflake
+ bindingTables:
+ - t_order,t_order_item
+ broadcastTables:
+ - t_address
+ defaultShardingColumn: account_id
+ defaultDatabaseStrategy:
+ standard:
+ shardingColumn: user_id
+ shardingAlgorithmName: database_spi_based
+
+ shardingAlgorithms:
+ database_spi_based:
+ type: DATABASE_SPI_BASED
+ t_order_spi_based:
+ type: T_ORDER_SPI_BASED
+ t_order_item_spi_based:
+ type: T_ORDER_SPI_BASED
+ t_account_spi_based:
+ type: T_ORDER_SPI_BASED
+
+ keyGenerators:
+ snowflake:
+ type: SNOWFLAKE
+
+props:
+ spl-show: true
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-jpa-example/src/main/resources/sharding-databases.yaml b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-jpa-example/src/main/resources/sharding-databases.yaml
new file mode 100644
index 00000000000..0a08488df0e
--- /dev/null
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-jpa-example/src/main/resources/sharding-databases.yaml
@@ -0,0 +1,63 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+dataSources:
+ ds_0:
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ jdbcUrl: jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+ username: root
+ password:
+ ds_1:
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ jdbcUrl: jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+ username: root
+ password:
+
+rules:
+- !SHARDING
+ tables:
+ t_order:
+ actualDataNodes: ds_${0..1}.t_order
+ keyGenerateStrategy:
+ column: order_id
+ keyGeneratorName: snowflake
+ t_order_item:
+ actualDataNodes: ds_${0..1}.t_order_item
+ keyGenerateStrategy:
+ column: order_item_id
+ keyGeneratorName: snowflake
+ bindingTables:
+ - t_order,t_order_item
+ broadcastTables:
+ - t_address
+ defaultDatabaseStrategy:
+ standard:
+ shardingColumn: user_id
+ shardingAlgorithmName: database_spi_based
+
+ shardingAlgorithms:
+ database_spi_based:
+ type: DATABASE_SPI_BASED
+
+ keyGenerators:
+ snowflake:
+ type: SNOWFLAKE
+
+props:
+ spl-show: true
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-jpa-example/src/main/resources/sharding-tables.yaml b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-jpa-example/src/main/resources/sharding-tables.yaml
new file mode 100644
index 00000000000..c53be009085
--- /dev/null
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-jpa-example/src/main/resources/sharding-tables.yaml
@@ -0,0 +1,74 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+dataSources:
+ ds:
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ jdbcUrl: jdbc:mysql://localhost:3306/demo_ds?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+ username: root
+ password:
+
+rules:
+- !SHARDING
+ tables:
+ t_order:
+ actualDataNodes: ds.t_order_$->{0..1}
+ tableStrategy:
+ standard:
+ shardingColumn: order_id
+ shardingAlgorithmName: t_order_spi_based
+ keyGenerateStrategy:
+ column: order_id
+ keyGeneratorName: snowflake
+ t_order_item:
+ actualDataNodes: ds.t_order_item_$->{0..1}
+ tableStrategy:
+ standard:
+ shardingColumn: order_id
+ shardingAlgorithmName: t_order_item_spi_based
+ keyGenerateStrategy:
+ column: order_item_id
+ keyGeneratorName: snowflake
+ t_account:
+ actualDataNodes: ds.t_account_$->{0..1}
+ tableStrategy:
+ standard:
+ shardingAlgorithmName: t_account_spi_based
+ keyGenerateStrategy:
+ column: order_item_id
+ keyGeneratorName: snowflake
+ bindingTables:
+ - t_order,t_order_item
+ broadcastTables:
+ - t_address
+ defaultShardingColumn: account_id
+
+ shardingAlgorithms:
+ t_order_spi_based:
+ type: T_ORDER_SPI_BASED
+ t_order_item_spi_based:
+ type: T_ORDER_SPI_BASED
+ t_account_spi_based:
+ type: T_ORDER_SPI_BASED
+
+ keyGenerators:
+ snowflake:
+ type: SNOWFLAKE
+
+props:
+ spl-show: true
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/pom.xml b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/pom.xml
index 9e916163b3b..af1bf0f4ebc 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/pom.xml
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/pom.xml
@@ -37,7 +37,7 @@
<dependency>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-jdbc-core-spring-boot-starter</artifactId>
+ <artifactId>shardingsphere-jdbc-core</artifactId>
</dependency>
<dependency>
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/java/org/apache/shardingsphere/example/extension/spibased/sharding/spring/boot/mybatis/fixture/SPIBasedDataSourceStandardShardingAlgorithmFixture.java b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based- [...]
similarity index 93%
rename from examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/java/org/apache/shardingsphere/example/extension/spibased/sharding/spring/boot/mybatis/fixture/SPIBasedDataSourceStandardShardingAlgorithmFixture.java
rename to examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/java/org/apache/shardingsphere/example/extension/spibased/sharding/spring/boot/mybatis/fixture/SPIBasedDatabaseStandardShardingAlgorithmFixture.java
index 857bf03474a..6ee005a8a55 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/java/org/apache/shardingsphere/example/extension/spibased/sharding/spring/boot/mybatis/fixture/SPIBasedDataSourceStandardShardingAlgorithmFixture.java
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/java/org/apache/shardingsphere/example/extension/spibased/sharding/spring/boot/mybatis/fixture/SPIBasedDatabaseStandardShardingAlgorithmFixture.java
@@ -26,7 +26,7 @@ import java.util.Collection;
import java.util.Properties;
@Getter
-public final class SPIBasedDataSourceStandardShardingAlgorithmFixture implements StandardShardingAlgorithm<Integer> {
+public final class SPIBasedDatabaseStandardShardingAlgorithmFixture implements StandardShardingAlgorithm<Integer> {
private Properties props;
@@ -56,6 +56,6 @@ public final class SPIBasedDataSourceStandardShardingAlgorithmFixture implements
@Override
public String getType() {
- return "DATASOURCE_SPI_BASED";
+ return "DATABASE_SPI_BASED";
}
}
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/resources/META-INF/services/org.apache.shardingsphere.sharding.spi.ShardingAlgorithm b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis- [...]
index f4cf9e78d46..8df1fcc0f70 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/resources/META-INF/services/org.apache.shardingsphere.sharding.spi.ShardingAlgorithm
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/resources/META-INF/services/org.apache.shardingsphere.sharding.spi.ShardingAlgorithm
@@ -17,4 +17,4 @@
org.apache.shardingsphere.example.extension.spibased.sharding.spring.boot.mybatis.fixture.SPIBasedOrderStandardShardingAlgorithmFixture
org.apache.shardingsphere.example.extension.spibased.sharding.spring.boot.mybatis.fixture.SPIBasedOrderItemStandardShardingAlgorithmFixture
-org.apache.shardingsphere.example.extension.spibased.sharding.spring.boot.mybatis.fixture.SPIBasedDataSourceStandardShardingAlgorithmFixture
+org.apache.shardingsphere.example.extension.spibased.sharding.spring.boot.mybatis.fixture.SPIBasedDatabaseStandardShardingAlgorithmFixture
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-auto-tables.properties b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/resources/appl [...]
index 5a420632c1b..0e64cb7cbf7 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-auto-tables.properties
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-auto-tables.properties
@@ -15,41 +15,5 @@
# limitations under the License.
#
-spring.shardingsphere.datasource.names=ds-0,ds-1
-
-spring.shardingsphere.datasource.ds-0.jdbc-url=jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
-spring.shardingsphere.datasource.ds-0.type=com.zaxxer.hikari.HikariDataSource
-spring.shardingsphere.datasource.ds-0.driver-class-name=com.mysql.jdbc.Driver
-spring.shardingsphere.datasource.ds-0.username=root
-spring.shardingsphere.datasource.ds-0.password=
-
-spring.shardingsphere.datasource.ds-1.jdbc-url=jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
-spring.shardingsphere.datasource.ds-1.type=com.zaxxer.hikari.HikariDataSource
-spring.shardingsphere.datasource.ds-1.driver-class-name=com.mysql.jdbc.Driver
-spring.shardingsphere.datasource.ds-1.username=root
-spring.shardingsphere.datasource.ds-1.password=
-
-spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-column=user_id
-spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-algorithm-name=database-inline
-spring.shardingsphere.rules.sharding.binding-tables[0]=t_order,t_order_item
-
-spring.shardingsphere.rules.sharding.autotables.t_order.actual-datasources=ds-${0..1}
-
-spring.shardingsphere.rules.sharding.auto-tables.t_order.sharding-strategy.standard.sharding-column=order_id
-spring.shardingsphere.rules.sharding.auto-tables.t_order.sharding-strategy.standard.sharding-algorithm-name=auto-mod
-
-spring.shardingsphere.rules.sharding.auto-tables.t_order.key-generate-strategy.column=order_id
-spring.shardingsphere.rules.sharding.auto-tables.t_order.key-generate-strategy.key-generator-name=snowflake
-
-spring.shardingsphere.rules.sharding.auto-tables.t_order_item.actual-datasources=ds-${0..1}
-
-spring.shardingsphere.rules.sharding.auto-tables.t_order_item.sharding-strategy.standard.sharding-column=order_item_id
-spring.shardingsphere.rules.sharding.auto-tables.t_order_item.sharding-strategy.standard.sharding-algorithm-name=auto-mod
-
-spring.shardingsphere.rules.sharding.auto-tables.t_order_item.key-generate-strategy.column=order_item_id
-spring.shardingsphere.rules.sharding.auto-tables.t_order_item.key-generate-strategy.key-generator-name=snowflake
-
-spring.shardingsphere.rules.sharding.sharding-algorithms.auto-mod.type=mod
-spring.shardingsphere.rules.sharding.sharding-algorithms.auto-mod.props.sharding-count=4
-
-spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE
+spring.datasource.driver-class-name=org.apache.shardingsphere.driver.ShardingSphereDriver
+spring.datasource.url=jdbc:shardingsphere:classpath:sharding-auto-tables.yaml
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-databases-tables.properties b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/resources [...]
index fb213c1ee75..12969865b87 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-databases-tables.properties
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-databases-tables.properties
@@ -15,44 +15,5 @@
# limitations under the License.
#
-spring.shardingsphere.mode.type=Standalone
-spring.shardingsphere.mode.repository.type=H2
-
-spring.shardingsphere.datasource.names=ds-0,ds-1
-
-spring.shardingsphere.datasource.ds-0.jdbc-url=jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
-spring.shardingsphere.datasource.ds-0.type=com.zaxxer.hikari.HikariDataSource
-spring.shardingsphere.datasource.ds-0.driver-class-name=com.mysql.jdbc.Driver
-spring.shardingsphere.datasource.ds-0.username=root
-spring.shardingsphere.datasource.ds-0.password=
-
-spring.shardingsphere.datasource.ds-1.jdbc-url=jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
-spring.shardingsphere.datasource.ds-1.type=com.zaxxer.hikari.HikariDataSource
-spring.shardingsphere.datasource.ds-1.driver-class-name=com.mysql.jdbc.Driver
-spring.shardingsphere.datasource.ds-1.username=root
-spring.shardingsphere.datasource.ds-1.password=
-
-spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-column=user_id
-spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-algorithm-name=datasource-spi-based
-spring.shardingsphere.rules.sharding.binding-tables[0]=t_order,t_order_item
-spring.shardingsphere.rules.sharding.broadcast-tables=t_address
-
-spring.shardingsphere.rules.sharding.tables.t_order.actual-data-nodes=ds-$->{0..1}.t_order_$->{0..1}
-spring.shardingsphere.rules.sharding.tables.t_order.table-strategy.standard.sharding-column=order_id
-spring.shardingsphere.rules.sharding.tables.t_order.table-strategy.standard.sharding-algorithm-name=t-order-spi-based
-
-spring.shardingsphere.rules.sharding.tables.t_order.key-generate-strategy.column=order_id
-spring.shardingsphere.rules.sharding.tables.t_order.key-generate-strategy.key-generator-name=snowflake
-
-spring.shardingsphere.rules.sharding.tables.t_order_item.actual-data-nodes=ds-$->{0..1}.t_order_item_$->{0..1}
-spring.shardingsphere.rules.sharding.tables.t_order_item.table-strategy.standard.sharding-column=order_id
-spring.shardingsphere.rules.sharding.tables.t_order_item.table-strategy.standard.sharding-algorithm-name=t-order-item-spi-based
-
-spring.shardingsphere.rules.sharding.tables.t_order_item.key-generate-strategy.column=order_item_id
-spring.shardingsphere.rules.sharding.tables.t_order_item.key-generate-strategy.key-generator-name=snowflake
-
-spring.shardingsphere.rules.sharding.sharding-algorithms.datasource-spi-based.type=DATASOURCE_SPI_BASED
-spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-spi-based.type=T_ORDER_SPI_BASED
-spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-item-spi-based.type=T_ORDER_ITEM_SPI_BASED
-
-spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE
+spring.datasource.driver-class-name=org.apache.shardingsphere.driver.ShardingSphereDriver
+spring.datasource.url=jdbc:shardingsphere:classpath:sharding-databases-tables.yaml
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-databases.properties b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/resources/applic [...]
index d862b38b2f5..c3a61cc66a5 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-databases.properties
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-databases.properties
@@ -15,35 +15,5 @@
# limitations under the License.
#
-spring.shardingsphere.datasource.names=ds-0,ds-1
-
-spring.shardingsphere.datasource.ds-0.jdbc-url=jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
-spring.shardingsphere.datasource.ds-0.type=com.zaxxer.hikari.HikariDataSource
-spring.shardingsphere.datasource.ds-0.driver-class-name=com.mysql.jdbc.Driver
-spring.shardingsphere.datasource.ds-0.username=root
-spring.shardingsphere.datasource.ds-0.password=
-
-spring.shardingsphere.datasource.ds-1.jdbc-url=jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
-spring.shardingsphere.datasource.ds-1.type=com.zaxxer.hikari.HikariDataSource
-spring.shardingsphere.datasource.ds-1.driver-class-name=com.mysql.jdbc.Driver
-spring.shardingsphere.datasource.ds-1.username=root
-spring.shardingsphere.datasource.ds-1.password=
-
-spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-column=user_id
-spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-algorithm-name=datasource-spi-based
-spring.shardingsphere.rules.sharding.binding-tables[0]=t_order,t_order_item
-spring.shardingsphere.rules.sharding.broadcast-tables=t_address
-
-spring.shardingsphere.rules.sharding.tables.t_order.actual-data-nodes=ds-$->{0..1}.t_order
-
-spring.shardingsphere.rules.sharding.tables.t_order.key-generate-strategy.column=order_id
-spring.shardingsphere.rules.sharding.tables.t_order.key-generate-strategy.key-generator-name=snowflake
-
-spring.shardingsphere.rules.sharding.tables.t_order_item.actual-data-nodes=ds-$->{0..1}.t_order_item
-
-spring.shardingsphere.rules.sharding.tables.t_order_item.key-generate-strategy.column=order_item_id
-spring.shardingsphere.rules.sharding.tables.t_order_item.key-generate-strategy.key-generator-name=snowflake
-
-spring.shardingsphere.rules.sharding.sharding-algorithms.datasource-spi-based.type=DATASOURCE_SPI_BASED
-
-spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE
+spring.datasource.driver-class-name=org.apache.shardingsphere.driver.ShardingSphereDriver
+spring.datasource.url=jdbc:shardingsphere:classpath:sharding-databases.yaml
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-tables.properties b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/resources/applicati [...]
index b973e44d951..4b6a1fe81b0 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-tables.properties
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-tables.properties
@@ -15,34 +15,5 @@
# limitations under the License.
#
-spring.shardingsphere.mode.type=Memory
-
-spring.shardingsphere.datasource.names=ds
-
-spring.shardingsphere.datasource.ds.type=com.zaxxer.hikari.HikariDataSource
-spring.shardingsphere.datasource.ds.driver-class-name=com.mysql.jdbc.Driver
-spring.shardingsphere.datasource.ds.jdbc-url=jdbc:mysql://localhost:3306/demo_ds?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
-spring.shardingsphere.datasource.ds.username=root
-spring.shardingsphere.datasource.ds.password=123456789
-
-spring.shardingsphere.rules.sharding.tables.t_order.actual-data-nodes=ds.t_order_$->{0..1}
-spring.shardingsphere.rules.sharding.tables.t_order.table-strategy.standard.sharding-column=order_id
-spring.shardingsphere.rules.sharding.tables.t_order.table-strategy.standard.sharding-algorithm-name=t-order-spi-based
-
-spring.shardingsphere.rules.sharding.tables.t_order.key-generate-strategy.column=order_id
-spring.shardingsphere.rules.sharding.tables.t_order.key-generate-strategy.key-generator-name=snowflake
-
-spring.shardingsphere.rules.sharding.tables.t_order_item.actual-data-nodes=ds.t_order_item_$->{0..1}
-spring.shardingsphere.rules.sharding.tables.t_order_item.table-strategy.standard.sharding-column=order_id
-spring.shardingsphere.rules.sharding.tables.t_order_item.table-strategy.standard.sharding-algorithm-name=t-order-item-spi-based
-
-spring.shardingsphere.rules.sharding.tables.t_order_item.key-generate-strategy.column=order_item_id
-spring.shardingsphere.rules.sharding.tables.t_order_item.key-generate-strategy.key-generator-name=snowflake
-
-spring.shardingsphere.rules.sharding.binding-tables[0]=t_order,t_order_item
-spring.shardingsphere.rules.sharding.broadcast-tables=t_address
-
-spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-spi-based.type=T_ORDER_SPI_BASED
-spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-item-spi-based.type=T_ORDER_ITEM_SPI_BASED
-
-spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE
+spring.datasource.driver-class-name=org.apache.shardingsphere.driver.ShardingSphereDriver
+spring.datasource.url=jdbc:shardingsphere:classpath:sharding-tables.yaml
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/resources/sharding-auto-tables.yaml b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/resources/sharding-auto-tables.yaml
new file mode 100644
index 00000000000..487b70029e3
--- /dev/null
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/resources/sharding-auto-tables.yaml
@@ -0,0 +1,67 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+dataSources:
+ ds_0:
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ jdbcUrl: jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+ username: root
+ password:
+ ds_1:
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ jdbcUrl: jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+ username: root
+ password:
+
+rules:
+- !SHARDING
+ autoTables:
+ t_order:
+ actualDataSources: ds_${0..1}
+ shardingStrategy:
+ standard:
+ shardingColumn: order_id
+ shardingAlgorithmName: auto_mod
+ keyGenerateStrategy:
+ column: order_id
+ keyGeneratorName: snowflake
+ t_order_item:
+ actualDataSources: ds_${0..1}
+ shardingStrategy:
+ standard:
+ shardingColumn: order_item_id
+ shardingAlgorithmName: auto_mod
+ keyGenerateStrategy:
+ column: order_item_id
+ keyGeneratorName: snowflake
+ bindingTables:
+ - t_order,t_order_item
+
+ shardingAlgorithms:
+ auto_mod:
+ type: mod
+ props:
+ sharding-count: 4
+
+ keyGenerators:
+ snowflake:
+ type: SNOWFLAKE
+
+props:
+ spl-show: true
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/resources/sharding-databases-tables.yaml b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/resources/sharding-database [...]
new file mode 100644
index 00000000000..010d89195f7
--- /dev/null
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/resources/sharding-databases-tables.yaml
@@ -0,0 +1,75 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+dataSources:
+ ds_0:
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ jdbcUrl: jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+ username: root
+ password:
+ ds_1:
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ jdbcUrl: jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+ username: root
+ password:
+
+rules:
+- !SHARDING
+ tables:
+ t_order:
+ actualDataNodes: ds_${0..1}.t_order_$->{0..1}
+ tableStrategy:
+ standard:
+ shardingColumn: order_id
+ shardingAlgorithmName: t_order_spi_based
+ keyGenerateStrategy:
+ column: order_id
+ keyGeneratorName: snowflake
+ t_order_item:
+ actualDataNodes: ds_${0..1}.t_order_item_$->{0..1}
+ tableStrategy:
+ standard:
+ shardingColumn: order_id
+ shardingAlgorithmName: t_order_item_spi_based
+ keyGenerateStrategy:
+ column: order_item_id
+ keyGeneratorName: snowflake
+ bindingTables:
+ - t_order,t_order_item
+ broadcastTables:
+ - t_address
+ defaultDatabaseStrategy:
+ standard:
+ shardingColumn: user_id
+ shardingAlgorithmName: database_spi_based
+
+ shardingAlgorithms:
+ database_spi_based:
+ type: DATABASE_SPI_BASED
+ t_order_spi_based:
+ type: T_ORDER_SPI_BASED
+ t_order_item_spi_based:
+ type: T_ORDER_ITEM_SPI_BASED
+
+ keyGenerators:
+ snowflake:
+ type: SNOWFLAKE
+
+props:
+ spl-show: true
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/resources/sharding-databases.yaml b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/resources/sharding-databases.yaml
new file mode 100644
index 00000000000..0a08488df0e
--- /dev/null
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/resources/sharding-databases.yaml
@@ -0,0 +1,63 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+dataSources:
+ ds_0:
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ jdbcUrl: jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+ username: root
+ password:
+ ds_1:
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ jdbcUrl: jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+ username: root
+ password:
+
+rules:
+- !SHARDING
+ tables:
+ t_order:
+ actualDataNodes: ds_${0..1}.t_order
+ keyGenerateStrategy:
+ column: order_id
+ keyGeneratorName: snowflake
+ t_order_item:
+ actualDataNodes: ds_${0..1}.t_order_item
+ keyGenerateStrategy:
+ column: order_item_id
+ keyGeneratorName: snowflake
+ bindingTables:
+ - t_order,t_order_item
+ broadcastTables:
+ - t_address
+ defaultDatabaseStrategy:
+ standard:
+ shardingColumn: user_id
+ shardingAlgorithmName: database_spi_based
+
+ shardingAlgorithms:
+ database_spi_based:
+ type: DATABASE_SPI_BASED
+
+ keyGenerators:
+ snowflake:
+ type: SNOWFLAKE
+
+props:
+ spl-show: true
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/resources/sharding-tables.yaml b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/resources/sharding-tables.yaml
new file mode 100644
index 00000000000..00c0752760e
--- /dev/null
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/resources/sharding-tables.yaml
@@ -0,0 +1,63 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+dataSources:
+ ds:
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ jdbcUrl: jdbc:mysql://localhost:3306/demo_ds?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+ username: root
+ password:
+
+rules:
+- !SHARDING
+ tables:
+ t_order:
+ actualDataNodes: ds.t_order_$->{0..1}
+ tableStrategy:
+ standard:
+ shardingColumn: order_id
+ shardingAlgorithmName: t_order_spi_based
+ keyGenerateStrategy:
+ column: order_id
+ keyGeneratorName: snowflake
+ t_order_item:
+ actualDataNodes: ds.t_order_item_$->{0..1}
+ tableStrategy:
+ standard:
+ shardingColumn: order_id
+ shardingAlgorithmName: t_order_item_spi_based
+ keyGenerateStrategy:
+ column: order_item_id
+ keyGeneratorName: snowflake
+ bindingTables:
+ - t_order,t_order_item
+ broadcastTables:
+ - t_address
+
+ shardingAlgorithms:
+ t_order_spi_based:
+ type: T_ORDER_SPI_BASED
+ t_order_item_spi_based:
+ type: T_ORDER_SPI_BASED
+
+ keyGenerators:
+ snowflake:
+ type: SNOWFLAKE
+
+props:
+ spl-show: true
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-jpa-example/pom.xml b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-jpa-example/pom.xml
index 302433101c5..0711dc58294 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-jpa-example/pom.xml
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-jpa-example/pom.xml
@@ -37,7 +37,7 @@
<dependency>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-jdbc-core-spring-namespace</artifactId>
+ <artifactId>shardingsphere-jdbc-core</artifactId>
</dependency>
</dependencies>
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/extension/spibased/sharding/spring/namespace/jpa/fixture/SPIBasedDataSourceStandardShardingAlgorithmFixture.java b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-base [...]
similarity index 93%
rename from examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/extension/spibased/sharding/spring/namespace/jpa/fixture/SPIBasedDataSourceStandardShardingAlgorithmFixture.java
rename to examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/extension/spibased/sharding/spring/namespace/jpa/fixture/SPIBasedDatabaseStandardShardingAlgorithmFixture.java
index c524f9bf7be..650b3f214d4 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/extension/spibased/sharding/spring/namespace/jpa/fixture/SPIBasedDataSourceStandardShardingAlgorithmFixture.java
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/extension/spibased/sharding/spring/namespace/jpa/fixture/SPIBasedDatabaseStandardShardingAlgorithmFixture.java
@@ -26,7 +26,7 @@ import java.util.Collection;
import java.util.Properties;
@Getter
-public final class SPIBasedDataSourceStandardShardingAlgorithmFixture implements StandardShardingAlgorithm<Integer> {
+public final class SPIBasedDatabaseStandardShardingAlgorithmFixture implements StandardShardingAlgorithm<Integer> {
private Properties props;
@@ -56,6 +56,6 @@ public final class SPIBasedDataSourceStandardShardingAlgorithmFixture implements
@Override
public String getType() {
- return "DATASOURCE_SPI_BASED";
+ return "DATABASE_SPI_BASED";
}
}
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-jpa-example/src/main/resources/META-INF/application-sharding-databases-tables.xml b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-jpa-example/src/main/resou [...]
index fc5942b91fd..e9456f07c03 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-jpa-example/src/main/resources/META-INF/application-sharding-databases-tables.xml
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-jpa-example/src/main/resources/META-INF/application-sharding-databases-tables.xml
@@ -21,22 +21,21 @@
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:shardingsphere="http://shardingsphere.apache.org/schema/shardingsphere/datasource"
- 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://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/datasource
- http://shardingsphere.apache.org/schema/shardingsphere/datasource/datasource.xsd
- http://shardingsphere.apache.org/schema/shardingsphere/sharding
- http://shardingsphere.apache.org/schema/shardingsphere/sharding/sharding.xsd
">
<context:annotation-config />
<context:component-scan base-package="org.apache.shardingsphere.example.core.jpa" />
-
+
+ <bean id="shardingDataSource" class="org.springframework.jdbc.datasource.SimpleDriverDataSource">
+ <property name="driverClass" value="org.apache.shardingsphere.driver.ShardingSphereDriver" />
+ <property name="url" value="jdbc:shardingsphere:classpath:sharding-databases-tables.yaml" />
+ </bean>
+
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="shardingDataSource" />
<property name="jpaVendorAdapter">
@@ -53,59 +52,4 @@
</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?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8" />
- <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?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8" />
- <property name="username" value="root" />
- <property name="password" value="" />
- <property name="maximumPoolSize" value="16" />
- </bean>
-
- <sharding:sharding-algorithm id="databaseAlgorithm" type="DATASOURCE_SPI_BASED" />
- <sharding:standard-strategy id="databaseStrategy" sharding-column="user_id" algorithm-ref="databaseAlgorithm" />
-
- <sharding:sharding-algorithm id="accountTableAlgorithm" type="T_ACCOUNT_SPI_BASED" />
- <sharding:standard-strategy id="accountTableStrategy" algorithm-ref="accountTableAlgorithm" />
-
- <sharding:sharding-algorithm id="orderTableAlgorithm" type="T_ORDER_SPI_BASED" />
- <sharding:standard-strategy id="orderTableStrategy" sharding-column="order_id" algorithm-ref="orderTableAlgorithm" />
-
- <sharding:sharding-algorithm id="orderItemTableAlgorithm" type="T_ORDER_SPI_BASED" />
- <sharding:standard-strategy id="orderItemTableStrategy" sharding-column="order_id" algorithm-ref="orderItemTableAlgorithm" />
-
- <sharding:key-generate-algorithm id="snowflakeAlgorithm" type="SNOWFLAKE">
- </sharding:key-generate-algorithm>
-
- <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:key-generate-strategy id="accountKeyGenerator" column="account_id" algorithm-ref="snowflakeAlgorithm" />
-
- <sharding:rule id="shardingRule" default-sharding-column="account_id">
- <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-rule logic-table="t_account" actual-data-nodes="demo_ds_${0..1}.t_account_${0..1}" database-strategy-ref="databaseStrategy" table-strategy-ref="accountTableStrategy" key-generate-strategy-ref="accountKeyGenerator" />
- </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_address" />
- </sharding:broadcast-table-rules>
- </sharding:rule>
-
- <shardingsphere:data-source id="shardingDataSource" data-source-names="demo_ds_0, demo_ds_1" rule-refs="shardingRule">
- <props>
- <prop key="sql-show">false</prop>
- </props>
- </shardingsphere:data-source>
</beans>
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-jpa-example/src/main/resources/META-INF/application-sharding-databases.xml b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-jpa-example/src/main/resources/ME [...]
index 2fe264ee9c4..ec6fbc97aa0 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-jpa-example/src/main/resources/META-INF/application-sharding-databases.xml
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-jpa-example/src/main/resources/META-INF/application-sharding-databases.xml
@@ -21,22 +21,21 @@
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:shardingsphere="http://shardingsphere.apache.org/schema/shardingsphere/datasource"
- 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://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/datasource
- http://shardingsphere.apache.org/schema/shardingsphere/datasource/datasource.xsd
- http://shardingsphere.apache.org/schema/shardingsphere/sharding
- http://shardingsphere.apache.org/schema/shardingsphere/sharding/sharding.xsd
">
<context:annotation-config />
<context:component-scan base-package="org.apache.shardingsphere.example.core.jpa" />
+ <bean id="shardingDataSource" class="org.springframework.jdbc.datasource.SimpleDriverDataSource">
+ <property name="driverClass" value="org.apache.shardingsphere.driver.ShardingSphereDriver" />
+ <property name="url" value="jdbc:shardingsphere:classpath:sharding-databases.yaml" />
+ </bean>
+
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="shardingDataSource" />
<property name="jpaVendorAdapter">
@@ -53,44 +52,4 @@
</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?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8" />
- <property name="username" value="root" />
- <property name="password" value="" />
- </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?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8" />
- <property name="username" value="root" />
- <property name="password" value="" />
- </bean>
-
- <sharding:sharding-algorithm id="databaseAlgorithm" type="DATASOURCE_SPI_BASED" />
- <sharding:standard-strategy id="databaseStrategy" sharding-column="user_id" algorithm-ref="databaseAlgorithm" />
-
- <sharding:key-generate-algorithm id="snowflakeAlgorithm" type="SNOWFLAKE">
- </sharding:key-generate-algorithm>
-
- <sharding:key-generate-strategy id="orderKeyGenerator" column="order_id" algorithm-ref="snowflakeAlgorithm" />
- <sharding:key-generate-strategy id="accountKeyGenerator" column="account_id" algorithm-ref="snowflakeAlgorithm" />
- <sharding:key-generate-strategy id="itemKeyGenerator" column="order_item_id" algorithm-ref="snowflakeAlgorithm" />
-
- <sharding:rule id="shardingRule">
- <sharding:table-rules>
- <sharding:table-rule logic-table="t_order" database-strategy-ref="databaseStrategy" key-generate-strategy-ref="orderKeyGenerator" />
- <sharding:table-rule logic-table="t_order_item" database-strategy-ref="databaseStrategy" key-generate-strategy-ref="itemKeyGenerator" />
- <sharding:table-rule logic-table="t_account" database-strategy-ref="databaseStrategy" key-generate-strategy-ref="accountKeyGenerator" />
- </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_address" />
- </sharding:broadcast-table-rules>
- </sharding:rule>
-
- <shardingsphere:data-source id="shardingDataSource" data-source-names="demo_ds_0, demo_ds_1" rule-refs="shardingRule" />
</beans>
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-jpa-example/src/main/resources/META-INF/application-sharding-tables.xml b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-jpa-example/src/main/resources/META- [...]
index a2379897377..bb09a867dbe 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-jpa-example/src/main/resources/META-INF/application-sharding-tables.xml
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-jpa-example/src/main/resources/META-INF/application-sharding-tables.xml
@@ -21,22 +21,21 @@
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:shardingsphere="http://shardingsphere.apache.org/schema/shardingsphere/datasource"
- 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://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/datasource
- http://shardingsphere.apache.org/schema/shardingsphere/datasource/datasource.xsd
- http://shardingsphere.apache.org/schema/shardingsphere/sharding
- http://shardingsphere.apache.org/schema/shardingsphere/sharding/sharding.xsd
">
<context:annotation-config />
<context:component-scan base-package="org.apache.shardingsphere.example.core.jpa" />
+ <bean id="shardingDataSource" class="org.springframework.jdbc.datasource.SimpleDriverDataSource">
+ <property name="driverClass" value="org.apache.shardingsphere.driver.ShardingSphereDriver" />
+ <property name="url" value="jdbc:shardingsphere:classpath:sharding-tables.yaml" />
+ </bean>
+
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="shardingDataSource" />
<property name="jpaVendorAdapter">
@@ -53,43 +52,4 @@
</bean>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager" p:entityManagerFactory-ref="entityManagerFactory" />
<tx:annotation-driven />
-
- <bean id="demo_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?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8" />
- <property name="username" value="root" />
- <property name="password" value="" />
- </bean>
-
- <sharding:sharding-algorithm id="accountTableAlgorithm" type="T_ACCOUNT_SPI_BASED" />
- <sharding:standard-strategy id="accountTableStrategy" algorithm-ref="accountTableAlgorithm" />
-
- <sharding:sharding-algorithm id="orderTableAlgorithm" type="T_ORDER_SPI_BASED" />
- <sharding:standard-strategy id="orderTableStrategy" sharding-column="order_id" algorithm-ref="orderTableAlgorithm" />
-
- <sharding:sharding-algorithm id="orderItemTableAlgorithm" type="T_ORDER_ITEM_SPI_BASED" />
- <sharding:standard-strategy id="orderItemTableStrategy" sharding-column="order_id" algorithm-ref="orderItemTableAlgorithm" />
-
- <sharding:key-generate-algorithm id="snowflakeAlgorithm" type="SNOWFLAKE">
- </sharding:key-generate-algorithm>
-
- <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:key-generate-strategy id="accountKeyGenerator" column="account_id" algorithm-ref="snowflakeAlgorithm" />
-
- <sharding:rule id="shardingRule" default-sharding-column="account_id">
- <sharding:table-rules>
- <sharding:table-rule logic-table="t_order" actual-data-nodes="demo_ds.t_order_${0..1}" table-strategy-ref="orderTableStrategy" key-generate-strategy-ref="orderKeyGenerator" />
- <sharding:table-rule logic-table="t_order_item" actual-data-nodes="demo_ds.t_order_item_${0..1}" table-strategy-ref="orderItemTableStrategy" key-generate-strategy-ref="itemKeyGenerator" />
- <sharding:table-rule logic-table="t_account" actual-data-nodes="demo_ds.t_account_${0..1}" table-strategy-ref="accountTableStrategy" key-generate-strategy-ref="accountKeyGenerator" />
- </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_address" />
- </sharding:broadcast-table-rules>
- </sharding:rule>
-
- <shardingsphere:data-source id="shardingDataSource" data-source-names="demo_ds" rule-refs="shardingRule" />
</beans>
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-jpa-example/src/main/resources/META-INF/services/org.apache.shardingsphere.sharding.spi.ShardingAlgorithm b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-jp [...]
index 8961ae8bb59..df36f4e6a2a 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-jpa-example/src/main/resources/META-INF/services/org.apache.shardingsphere.sharding.spi.ShardingAlgorithm
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-jpa-example/src/main/resources/META-INF/services/org.apache.shardingsphere.sharding.spi.ShardingAlgorithm
@@ -15,7 +15,7 @@
# limitations under the License.
#
-org.apache.shardingsphere.example.extension.spibased.sharding.spring.namespace.jpa.fixture.SPIBasedDataSourceStandardShardingAlgorithmFixture
+org.apache.shardingsphere.example.extension.spibased.sharding.spring.namespace.jpa.fixture.SPIBasedDatabaseStandardShardingAlgorithmFixture
org.apache.shardingsphere.example.extension.spibased.sharding.spring.namespace.jpa.fixture.SPIBasedAccountStandardShardingAlgorithmFixture
org.apache.shardingsphere.example.extension.spibased.sharding.spring.namespace.jpa.fixture.SPIBasedOrderStandardShardingAlgorithmFixture
org.apache.shardingsphere.example.extension.spibased.sharding.spring.namespace.jpa.fixture.SPIBasedOrderItemStandardShardingAlgorithmFixture
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-jpa-example/src/main/resources/sharding-databases-tables.yaml b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-jpa-example/src/main/resources/sharding-databa [...]
new file mode 100644
index 00000000000..51698fe4681
--- /dev/null
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-jpa-example/src/main/resources/sharding-databases-tables.yaml
@@ -0,0 +1,86 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+dataSources:
+ ds_0:
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ jdbcUrl: jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+ username: root
+ password:
+ ds_1:
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ jdbcUrl: jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+ username: root
+ password:
+
+rules:
+- !SHARDING
+ tables:
+ t_order:
+ actualDataNodes: ds_${0..1}.t_order_$->{0..1}
+ tableStrategy:
+ standard:
+ shardingColumn: order_id
+ shardingAlgorithmName: t_order_spi_based
+ keyGenerateStrategy:
+ column: order_id
+ keyGeneratorName: snowflake
+ t_order_item:
+ actualDataNodes: ds_${0..1}.t_order_item_$->{0..1}
+ tableStrategy:
+ standard:
+ shardingColumn: order_id
+ shardingAlgorithmName: t_order_item_spi_based
+ keyGenerateStrategy:
+ column: order_item_id
+ keyGeneratorName: snowflake
+ t_account:
+ actualDataNodes: ds_${0..1}.t_account_$->{0..1}
+ tableStrategy:
+ standard:
+ shardingAlgorithmName: t_account_spi_based
+ keyGenerateStrategy:
+ column: account_id
+ keyGeneratorName: snowflake
+ bindingTables:
+ - t_order,t_order_item
+ broadcastTables:
+ - t_address
+ defaultShardingColumn: account_id
+ defaultDatabaseStrategy:
+ standard:
+ shardingColumn: user_id
+ shardingAlgorithmName: database_spi_based
+
+ shardingAlgorithms:
+ database_spi_based:
+ type: DATABASE_SPI_BASED
+ t_order_spi_based:
+ type: T_ORDER_SPI_BASED
+ t_order_item_spi_based:
+ type: T_ORDER_SPI_BASED
+ t_account_spi_based:
+ type: T_ACCOUNT_SPI_BASED
+
+ keyGenerators:
+ snowflake:
+ type: SNOWFLAKE
+
+props:
+ spl-show: true
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-jpa-example/src/main/resources/sharding-databases.yaml b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-jpa-example/src/main/resources/sharding-databases.yaml
new file mode 100644
index 00000000000..39e73462973
--- /dev/null
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-jpa-example/src/main/resources/sharding-databases.yaml
@@ -0,0 +1,68 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+dataSources:
+ ds_0:
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ jdbcUrl: jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+ username: root
+ password:
+ ds_1:
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ jdbcUrl: jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+ username: root
+ password:
+
+rules:
+- !SHARDING
+ tables:
+ t_order:
+ actualDataNodes: ds_${0..1}.t_order
+ keyGenerateStrategy:
+ column: order_id
+ keyGeneratorName: snowflake
+ t_order_item:
+ actualDataNodes: ds_${0..1}.t_order_item
+ keyGenerateStrategy:
+ column: order_item_id
+ keyGeneratorName: snowflake
+ t_account:
+ actualDataNodes: ds_${0..1}.t_account
+ keyGenerateStrategy:
+ column: order_item_id
+ keyGeneratorName: snowflake
+ bindingTables:
+ - t_order,t_order_item
+ broadcastTables:
+ - t_address
+ defaultDatabaseStrategy:
+ standard:
+ shardingColumn: user_id
+ shardingAlgorithmName: database_spi_based
+
+ shardingAlgorithms:
+ database_spi_based:
+ type: DATABASE_SPI_BASED
+
+ keyGenerators:
+ snowflake:
+ type: SNOWFLAKE
+
+props:
+ spl-show: true
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-jpa-example/src/main/resources/sharding-tables.yaml b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-jpa-example/src/main/resources/sharding-tables.yaml
new file mode 100644
index 00000000000..b426e38cd5b
--- /dev/null
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-jpa-example/src/main/resources/sharding-tables.yaml
@@ -0,0 +1,74 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+dataSources:
+ ds:
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ jdbcUrl: jdbc:mysql://localhost:3306/demo_ds?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+ username: root
+ password:
+
+rules:
+- !SHARDING
+ tables:
+ t_order:
+ actualDataNodes: ds.t_order_$->{0..1}
+ tableStrategy:
+ standard:
+ shardingColumn: order_id
+ shardingAlgorithmName: t_order_spi_based
+ keyGenerateStrategy:
+ column: order_id
+ keyGeneratorName: snowflake
+ t_order_item:
+ actualDataNodes: ds.t_order_item_$->{0..1}
+ tableStrategy:
+ standard:
+ shardingColumn: order_id
+ shardingAlgorithmName: t_order_item_spi_based
+ keyGenerateStrategy:
+ column: order_item_id
+ keyGeneratorName: snowflake
+ t_account:
+ actualDataNodes: ds.t_account_$->{0..1}
+ tableStrategy:
+ standard:
+ shardingAlgorithmName: t_account_spi_based
+ keyGenerateStrategy:
+ column: account_id
+ keyGeneratorName: snowflake
+ bindingTables:
+ - t_order,t_order_item
+ broadcastTables:
+ - t_address
+ defaultShardingColumn: account_id
+
+ shardingAlgorithms:
+ t_order_spi_based:
+ type: T_ORDER_SPI_BASED
+ t_order_item_spi_based:
+ type: T_ORDER_SPI_BASED
+ t_account_spi_based:
+ type: T_ACCOUNT_SPI_BASED
+
+ keyGenerators:
+ snowflake:
+ type: SNOWFLAKE
+
+props:
+ spl-show: true
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-mybatis-example/pom.xml b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-mybatis-example/pom.xml
index 1a9b84d1560..9e68d7364ba 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-mybatis-example/pom.xml
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-mybatis-example/pom.xml
@@ -37,7 +37,7 @@
<dependency>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-jdbc-core-spring-namespace</artifactId>
+ <artifactId>shardingsphere-jdbc-core</artifactId>
</dependency>
</dependencies>
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/extension/spibased/sharding/spring/namespace/mybatis/fixture/SPIBasedDataSourceStandardShardingAlgorithmFixture.java b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/ [...]
similarity index 93%
rename from examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/extension/spibased/sharding/spring/namespace/mybatis/fixture/SPIBasedDataSourceStandardShardingAlgorithmFixture.java
rename to examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/extension/spibased/sharding/spring/namespace/mybatis/fixture/SPIBasedDatabaseStandardShardingAlgorithmFixture.java
index 2abe69969f8..f6585775d42 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/extension/spibased/sharding/spring/namespace/mybatis/fixture/SPIBasedDataSourceStandardShardingAlgorithmFixture.java
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/extension/spibased/sharding/spring/namespace/mybatis/fixture/SPIBasedDatabaseStandardShardingAlgorithmFixture.java
@@ -26,7 +26,7 @@ import java.util.Collection;
import java.util.Properties;
@Getter
-public final class SPIBasedDataSourceStandardShardingAlgorithmFixture implements StandardShardingAlgorithm<Integer> {
+public final class SPIBasedDatabaseStandardShardingAlgorithmFixture implements StandardShardingAlgorithm<Integer> {
private Properties props;
@@ -56,6 +56,6 @@ public final class SPIBasedDataSourceStandardShardingAlgorithmFixture implements
@Override
public String getType() {
- return "DATASOURCE_SPI_BASED";
+ return "DATABASE_SPI_BASED";
}
}
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-mybatis-example/src/main/resources/META-INF/application-sharding-databases-tables.xml b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-mybatis-example/src/ma [...]
index b4a6005b7e9..27dd84b840c 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-mybatis-example/src/main/resources/META-INF/application-sharding-databases-tables.xml
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-mybatis-example/src/main/resources/META-INF/application-sharding-databases-tables.xml
@@ -20,64 +20,20 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
- xmlns:shardingsphere="http://shardingsphere.apache.org/schema/shardingsphere/datasource"
- 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://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
- http://shardingsphere.apache.org/schema/shardingsphere/datasource
- http://shardingsphere.apache.org/schema/shardingsphere/datasource/datasource.xsd
- http://shardingsphere.apache.org/schema/shardingsphere/sharding
- http://shardingsphere.apache.org/schema/shardingsphere/sharding/sharding.xsd
">
<context:component-scan base-package="org.apache.shardingsphere.example.core.mybatis" />
-
- <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?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8" />
- <property name="username" value="root" />
- <property name="password" value="" />
- </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?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8" />
- <property name="username" value="root" />
- <property name="password" value="" />
+
+ <bean id="shardingDataSource" class="org.springframework.jdbc.datasource.SimpleDriverDataSource">
+ <property name="driverClass" value="org.apache.shardingsphere.driver.ShardingSphereDriver" />
+ <property name="url" value="jdbc:shardingsphere:classpath:sharding-databases-tables.yaml" />
</bean>
-
- <sharding:standard-strategy id="databaseStrategy" sharding-column="user_id" algorithm-ref="inlineStrategyShardingAlgorithm" />
-
- <sharding:sharding-algorithm id="inlineStrategyShardingAlgorithm" type="INLINE">
- <props>
- <prop key="algorithm-expression">demo_ds_${user_id % 2}</prop>
- </props>
- </sharding:sharding-algorithm>
-
- <sharding:key-generate-algorithm id="snowflakeAlgorithm" type="SNOWFLAKE">
- </sharding:key-generate-algorithm>
-
- <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:rule id="shardingRule">
- <sharding:table-rules>
- <sharding:table-rule logic-table="t_order" database-strategy-ref="databaseStrategy" key-generate-strategy-ref="orderKeyGenerator" />
- <sharding:table-rule logic-table="t_order_item" database-strategy-ref="databaseStrategy" 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_address" />
- </sharding:broadcast-table-rules>
- </sharding:rule>
-
- <shardingsphere:data-source id="shardingDataSource" database-name="sharding-databases" data-source-names="demo_ds_0, demo_ds_1" rule-refs="shardingRule" />
-
+
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="shardingDataSource" />
</bean>
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-mybatis-example/src/main/resources/META-INF/application-sharding-databases.xml b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-mybatis-example/src/main/reso [...]
index b4a6005b7e9..62b6576fb33 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-mybatis-example/src/main/resources/META-INF/application-sharding-databases.xml
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-mybatis-example/src/main/resources/META-INF/application-sharding-databases.xml
@@ -20,64 +20,20 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
- xmlns:shardingsphere="http://shardingsphere.apache.org/schema/shardingsphere/datasource"
- 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://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
- http://shardingsphere.apache.org/schema/shardingsphere/datasource
- http://shardingsphere.apache.org/schema/shardingsphere/datasource/datasource.xsd
- http://shardingsphere.apache.org/schema/shardingsphere/sharding
- http://shardingsphere.apache.org/schema/shardingsphere/sharding/sharding.xsd
">
<context:component-scan base-package="org.apache.shardingsphere.example.core.mybatis" />
-
- <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?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8" />
- <property name="username" value="root" />
- <property name="password" value="" />
- </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?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8" />
- <property name="username" value="root" />
- <property name="password" value="" />
+
+ <bean id="shardingDataSource" class="org.springframework.jdbc.datasource.SimpleDriverDataSource">
+ <property name="driverClass" value="org.apache.shardingsphere.driver.ShardingSphereDriver" />
+ <property name="url" value="jdbc:shardingsphere:classpath:sharding-databases.yaml" />
</bean>
-
- <sharding:standard-strategy id="databaseStrategy" sharding-column="user_id" algorithm-ref="inlineStrategyShardingAlgorithm" />
-
- <sharding:sharding-algorithm id="inlineStrategyShardingAlgorithm" type="INLINE">
- <props>
- <prop key="algorithm-expression">demo_ds_${user_id % 2}</prop>
- </props>
- </sharding:sharding-algorithm>
-
- <sharding:key-generate-algorithm id="snowflakeAlgorithm" type="SNOWFLAKE">
- </sharding:key-generate-algorithm>
-
- <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:rule id="shardingRule">
- <sharding:table-rules>
- <sharding:table-rule logic-table="t_order" database-strategy-ref="databaseStrategy" key-generate-strategy-ref="orderKeyGenerator" />
- <sharding:table-rule logic-table="t_order_item" database-strategy-ref="databaseStrategy" 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_address" />
- </sharding:broadcast-table-rules>
- </sharding:rule>
-
- <shardingsphere:data-source id="shardingDataSource" database-name="sharding-databases" data-source-names="demo_ds_0, demo_ds_1" rule-refs="shardingRule" />
-
+
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="shardingDataSource" />
</bean>
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-mybatis-example/src/main/resources/META-INF/application-sharding-tables.xml b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-mybatis-example/src/main/resourc [...]
index d5d15a6638f..9e4698bf9e0 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-mybatis-example/src/main/resources/META-INF/application-sharding-tables.xml
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-mybatis-example/src/main/resources/META-INF/application-sharding-tables.xml
@@ -20,77 +20,30 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
- xmlns:shardingsphere="http://shardingsphere.apache.org/schema/shardingsphere/datasource"
- 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://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
- http://shardingsphere.apache.org/schema/shardingsphere/datasource
- http://shardingsphere.apache.org/schema/shardingsphere/datasource/datasource.xsd
- http://shardingsphere.apache.org/schema/shardingsphere/sharding
- http://shardingsphere.apache.org/schema/shardingsphere/sharding/sharding.xsd
">
<context:component-scan base-package="org.apache.shardingsphere.example.core.mybatis" />
-
- <bean id="demo_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?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8" />
- <property name="username" value="root" />
- <property name="password" value="" />
+
+ <bean id="shardingDataSource" class="org.springframework.jdbc.datasource.SimpleDriverDataSource">
+ <property name="driverClass" value="org.apache.shardingsphere.driver.ShardingSphereDriver" />
+ <property name="url" value="jdbc:shardingsphere:classpath:sharding-tables.yaml" />
</bean>
-
- <sharding:standard-strategy id="orderTableStrategy" sharding-column="order_id" algorithm-ref="inlineOrderTableStrategyAlgorithm" />
- <sharding:standard-strategy id="orderItemTableStrategy" sharding-column="order_id" algorithm-ref="inlineOrderItemTableStrategyAlgorithm" />
-
- <sharding:sharding-algorithm id="inlineOrderTableStrategyAlgorithm" type="INLINE">
- <props>
- <prop key="algorithm-expression">t_order_${order_id % 2}</prop>
- </props>
- </sharding:sharding-algorithm>
- <sharding:sharding-algorithm id="inlineOrderItemTableStrategyAlgorithm" type="INLINE">
- <props>
- <prop key="algorithm-expression">t_order_item_${order_id % 2}</prop>
- </props>
- </sharding:sharding-algorithm>
-
- <sharding:key-generate-algorithm id="snowflakeAlgorithm" type="SNOWFLAKE">
- </sharding:key-generate-algorithm>
-
- <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:rule id="shardingRule">
- <sharding:table-rules>
- <sharding:table-rule logic-table="t_order" actual-data-nodes="demo_ds.t_order_${0..1}" table-strategy-ref="orderTableStrategy" key-generate-strategy-ref="orderKeyGenerator" />
- <sharding:table-rule logic-table="t_order_item" actual-data-nodes="demo_ds.t_order_item_${0..1}" 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_address" />
- </sharding:broadcast-table-rules>
- </sharding:rule>
-
- <shardingsphere:data-source id="shardingDataSource" data-source-names="demo_ds" rule-refs="shardingRule">
- <props>
- <prop key="sql-show">false</prop>
- </props>
- </shardingsphere:data-source>
-
+
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="shardingDataSource" />
</bean>
<tx:annotation-driven />
-
+
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="shardingDataSource" />
<property name="mapperLocations" value="classpath*:META-INF/mappers/*.xml" />
</bean>
-
+
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="org.apache.shardingsphere.example.core.mybatis.repository" />
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" />
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-mybatis-example/src/main/resources/META-INF/services/org.apache.shardingsphere.sharding.spi.ShardingAlgorithm b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespac [...]
index f7eaa033208..26c8d931d80 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-mybatis-example/src/main/resources/META-INF/services/org.apache.shardingsphere.sharding.spi.ShardingAlgorithm
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-mybatis-example/src/main/resources/META-INF/services/org.apache.shardingsphere.sharding.spi.ShardingAlgorithm
@@ -17,4 +17,4 @@
org.apache.shardingsphere.example.extension.spibased.sharding.spring.namespace.mybatis.fixture.SPIBasedOrderStandardShardingAlgorithmFixture
org.apache.shardingsphere.example.extension.spibased.sharding.spring.namespace.mybatis.fixture.SPIBasedOrderItemStandardShardingAlgorithmFixture
-org.apache.shardingsphere.example.extension.spibased.sharding.spring.namespace.mybatis.fixture.SPIBasedDataSourceStandardShardingAlgorithmFixture
+org.apache.shardingsphere.example.extension.spibased.sharding.spring.namespace.mybatis.fixture.SPIBasedDatabaseStandardShardingAlgorithmFixture
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-mybatis-example/src/main/resources/sharding-databases-tables.yaml b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-mybatis-example/src/main/resources/shardin [...]
new file mode 100644
index 00000000000..6bb456e0bc3
--- /dev/null
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-mybatis-example/src/main/resources/sharding-databases-tables.yaml
@@ -0,0 +1,65 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+dataSources:
+ ds_0:
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ jdbcUrl: jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+ username: root
+ password:
+ ds_1:
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ jdbcUrl: jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+ username: root
+ password:
+
+rules:
+- !SHARDING
+ tables:
+ t_order:
+ actualDataNodes: ds_${0..1}.t_order_$->{0..1}
+ keyGenerateStrategy:
+ column: order_id
+ keyGeneratorName: snowflake
+ t_order_item:
+ actualDataNodes: ds_${0..1}.t_order_item_$->{0..1}
+ keyGenerateStrategy:
+ column: order_item_id
+ keyGeneratorName: snowflake
+ bindingTables:
+ - t_order,t_order_item
+ broadcastTables:
+ - t_address
+ defaultDatabaseStrategy:
+ standard:
+ shardingColumn: user_id
+ shardingAlgorithmName: database_inline
+
+ shardingAlgorithms:
+ database_inline:
+ type: INLINE
+ props:
+ algorithm-expression: ds_${user_id % 2}
+
+ keyGenerators:
+ snowflake:
+ type: SNOWFLAKE
+
+props:
+ spl-show: true
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-mybatis-example/src/main/resources/sharding-databases.yaml b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-mybatis-example/src/main/resources/sharding-datab [...]
new file mode 100644
index 00000000000..4b8e2288f20
--- /dev/null
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-mybatis-example/src/main/resources/sharding-databases.yaml
@@ -0,0 +1,65 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+dataSources:
+ ds_0:
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ jdbcUrl: jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+ username: root
+ password:
+ ds_1:
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ jdbcUrl: jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+ username: root
+ password:
+
+rules:
+- !SHARDING
+ tables:
+ t_order:
+ actualDataNodes: ds_${0..1}.t_order
+ keyGenerateStrategy:
+ column: order_id
+ keyGeneratorName: snowflake
+ t_order_item:
+ actualDataNodes: ds_${0..1}.t_order_item
+ keyGenerateStrategy:
+ column: order_item_id
+ keyGeneratorName: snowflake
+ bindingTables:
+ - t_order,t_order_item
+ broadcastTables:
+ - t_address
+ defaultDatabaseStrategy:
+ standard:
+ shardingColumn: user_id
+ shardingAlgorithmName: database_inline
+
+ shardingAlgorithms:
+ database_inline:
+ type: INLINE
+ props:
+ algorithm-expression: ds_${user_id % 2}
+
+ keyGenerators:
+ snowflake:
+ type: SNOWFLAKE
+
+props:
+ spl-show: true
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-mybatis-example/src/main/resources/sharding-tables.yaml b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-mybatis-example/src/main/resources/sharding-tables.yaml
new file mode 100644
index 00000000000..746964c2ae9
--- /dev/null
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-namespace-mybatis-example/src/main/resources/sharding-tables.yaml
@@ -0,0 +1,67 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+dataSources:
+ ds:
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ jdbcUrl: jdbc:mysql://localhost:3306/demo_ds?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+ username: root
+ password:
+
+rules:
+- !SHARDING
+ tables:
+ t_order:
+ actualDataNodes: ds.t_order_$->{0..1}
+ tableStrategy:
+ standard:
+ shardingColumn: order_id
+ shardingAlgorithmName: t_order_inline
+ keyGenerateStrategy:
+ column: order_id
+ keyGeneratorName: snowflake
+ t_order_item:
+ actualDataNodes: ds.t_order_item_$->{0..1}
+ tableStrategy:
+ standard:
+ shardingColumn: order_id
+ shardingAlgorithmName: t_order_item_inline
+ keyGenerateStrategy:
+ column: order_item_id
+ keyGeneratorName: snowflake
+ bindingTables:
+ - t_order,t_order_item
+ broadcastTables:
+ - t_address
+
+ shardingAlgorithms:
+ t_order_inline:
+ type: INLINE
+ props:
+ algorithm-expression: t_order_${order_id % 2}
+ t_order_item_inline:
+ type: INLINE
+ props:
+ algorithm-expression: t_order_item_${order_id % 2}
+
+ keyGenerators:
+ snowflake:
+ type: SNOWFLAKE
+
+props:
+ spl-show: true