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 09:59:52 UTC
[shardingsphere] branch master updated: Refactor class-based-sharding-algorithm-example with ShardingSphereDriver (#22534)
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 794a8debb9f Refactor class-based-sharding-algorithm-example with ShardingSphereDriver (#22534)
794a8debb9f is described below
commit 794a8debb9f76d5a6cf77155735cae72a9170afa
Author: ChenJiaHao <37...@users.noreply.github.com>
AuthorDate: Wed Nov 30 17:59:45 2022 +0800
Refactor class-based-sharding-algorithm-example with ShardingSphereDriver (#22534)
---
.../pom.xml | 6 +-
...dDatabaseStandardShardingAlgorithmFixture.java} | 2 +-
...pplication-sharding-databases-tables.properties | 54 +-------------
.../application-sharding-databases.properties | 39 +---------
.../application-sharding-tables.properties | 3 +
.../main/resources/sharding-databases-tables.yaml | 87 ++++++++++++++++++++++
.../src/main/resources/sharding-databases.yaml | 67 +++++++++++++++++
.../src/main/resources/sharding-tables.yaml | 71 ++++++++++++++++++
.../pom.xml | 6 +-
...dDatabaseStandardShardingAlgorithmFixture.java} | 2 +-
...pplication-sharding-databases-tables.properties | 5 +-
.../application-sharding-databases.properties | 40 +---------
.../application-sharding-tables.properties | 39 +---------
.../src/main/resources/application.properties | 4 +-
.../main/resources/sharding-databases-tables.yaml | 87 ++++++++++++++++++++++
.../src/main/resources/sharding-databases.yaml | 67 +++++++++++++++++
.../src/main/resources/sharding-tables.yaml | 71 ++++++++++++++++++
.../pom.xml | 6 +-
...lassBasedShardingSpringNamespaceJpaExample.java | 4 +-
...dDatabaseStandardShardingAlgorithmFixture.java} | 0
.../application-sharding-databases-tables.xml | 72 +-----------------
.../META-INF/application-sharding-databases.xml | 51 +------------
.../META-INF/application-sharding-tables.xml | 57 +-------------
.../main/resources/sharding-databases-tables.yaml | 87 ++++++++++++++++++++++
.../src/main/resources/sharding-databases.yaml | 67 +++++++++++++++++
.../src/main/resources/sharding-tables.yaml | 71 ++++++++++++++++++
.../pom.xml | 2 +-
...dDatabaseStandardShardingAlgorithmFixture.java} | 2 +-
.../application-sharding-databases-tables.xml | 72 +-----------------
.../META-INF/application-sharding-databases.xml | 51 +------------
.../META-INF/application-sharding-tables.xml | 57 +-------------
.../main/resources/sharding-databases-tables.yaml | 87 ++++++++++++++++++++++
.../src/main/resources/sharding-databases.yaml | 67 +++++++++++++++++
.../src/main/resources/sharding-tables.yaml | 71 ++++++++++++++++++
34 files changed, 948 insertions(+), 526 deletions(-)
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-boot-jpa-example/pom.xml b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-boot-jpa-example/pom.xml
index 4f4781baf0b..0f7b95b4a96 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-boot-jpa-example/pom.xml
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-boot-jpa-example/pom.xml
@@ -36,15 +36,11 @@
</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>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-test</artifactId>
- </dependency>
</dependencies>
</project>
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-boot-jpa-example/src/main/java/org/apache/shardingsphere/example/extension/classbased/sharding/spring/boot/jpa/fixture/ClassBasedDataSourceStandardShardingAlgorithmFixture.java b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-base [...]
similarity index 95%
rename from examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-boot-jpa-example/src/main/java/org/apache/shardingsphere/example/extension/classbased/sharding/spring/boot/jpa/fixture/ClassBasedDataSourceStandardShardingAlgorithmFixture.java
rename to examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-boot-jpa-example/src/main/java/org/apache/shardingsphere/example/extension/classbased/sharding/spring/boot/jpa/fixture/ClassBasedDatabaseStandardShardingAlgorithmFixture.java
index b7e127f57dc..65f6888e4f0 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-boot-jpa-example/src/main/java/org/apache/shardingsphere/example/extension/classbased/sharding/spring/boot/jpa/fixture/ClassBasedDataSourceStandardShardingAlgorithmFixture.java
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-boot-jpa-example/src/main/java/org/apache/shardingsphere/example/extension/classbased/sharding/spring/boot/jpa/fixture/ClassBasedDatabaseStandardShardingAlgorithmFixture.java
@@ -27,7 +27,7 @@ import org.apache.shardingsphere.sharding.api.sharding.standard.StandardSharding
import java.util.Collection;
import java.util.Properties;
-public final class ClassBasedDataSourceStandardShardingAlgorithmFixture implements StandardShardingAlgorithm<Integer> {
+public final class ClassBasedDatabaseStandardShardingAlgorithmFixture implements StandardShardingAlgorithm<Integer> {
private static final String SHARDING_COUNT = "sharding-count";
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-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/class-based-sharding-algorithm-example/class-based-sharding-spring-boot-jpa-example/src/main/resources [...]
index ffca2dffcfb..12969865b87 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-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/class-based-sharding-algorithm-example/class-based-sharding-spring-boot-jpa-example/src/main/resources/application-sharding-databases-tables.properties
@@ -15,55 +15,5 @@
# limitations under the License.
#
-spring.shardingsphere.mode.type=Standalone
-spring.shardingsphere.mode.repository.type=JDBC
-
-spring.shardingsphere.datasource.names=ds-0,ds-1
-
-spring.shardingsphere.datasource.ds-0.jdbc-url=jdbc:mysql://127.0.0.1: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://127.0.0.1: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-class-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-class-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-class-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-class-based.type=CLASS_BASED
-spring.shardingsphere.rules.sharding.sharding-algorithms.datasource-class-based.props.strategy=standard
-spring.shardingsphere.rules.sharding.sharding-algorithms.datasource-class-based.props.algorithmClassName=org.apache.shardingsphere.example.extension.classbased.sharding.spring.boot.jpa.fixture.ClassBasedDataSourceStandardShardingAlgorithmFixture
-spring.shardingsphere.rules.sharding.sharding-algorithms.datasource-class-based.props.sharding-count=2
-spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-class-based.type=CLASS_BASED
-spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-class-based.props.strategy=standard
-spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-class-based.props.algorithmClassName=org.apache.shardingsphere.example.extension.classbased.sharding.spring.boot.jpa.fixture.ClassBasedOrderStandardShardingAlgorithmFixture
-spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-class-based.props.sharding-count=2
-spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-item-class-based.type=CLASS_BASED
-spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-item-class-based.props.strategy=standard
-spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-item-class-based.props.algorithmClassName=org.apache.shardingsphere.example.extension.classbased.sharding.spring.boot.jpa.fixture.ClassBasedOrderItemStandardShardingAlgorithmFixture
-spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-item-class-based.props.sharding-count=2
-
-spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE
-
-spring.shardingsphere.props.sql-show=true
+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/class-based-sharding-algorithm-example/class-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/class-based-sharding-algorithm-example/class-based-sharding-spring-boot-jpa-example/src/main/resources/applic [...]
index 42502ff9698..c3a61cc66a5 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-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/class-based-sharding-algorithm-example/class-based-sharding-spring-boot-jpa-example/src/main/resources/application-sharding-databases.properties
@@ -15,40 +15,5 @@
# limitations under the License.
#
-spring.shardingsphere.datasource.names=ds-0,ds-1
-
-spring.shardingsphere.datasource.ds-0.jdbc-url=jdbc:mysql://127.0.0.1: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://127.0.0.1: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-class-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-class-based.type=CLASS_BASED
-spring.shardingsphere.rules.sharding.sharding-algorithms.datasource-class-based.props.strategy=standard
-spring.shardingsphere.rules.sharding.sharding-algorithms.datasource-class-based.props.algorithmClassName=org.apache.shardingsphere.example.extension.classbased.sharding.spring.boot.jpa.fixture.ClassBasedDataSourceStandardShardingAlgorithmFixture
-spring.shardingsphere.rules.sharding.sharding-algorithms.datasource-class-based.props.sharding-count=2
-
-spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE
-
-spring.shardingsphere.props.sql-show=true
+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/class-based-sharding-algorithm-example/class-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/class-based-sharding-algorithm-example/class-based-sharding-spring-boot-jpa-example/src/main/resources/applicati [...]
index 16f4f4bf3ce..4f8533ea598 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-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/class-based-sharding-algorithm-example/class-based-sharding-spring-boot-jpa-example/src/main/resources/application-sharding-tables.properties
@@ -15,6 +15,9 @@
# limitations under the License.
#
+spring.datasource.driver-class-name=org.apache.shardingsphere.driver.ShardingSphereDriver
+spring.datasource.url=jdbc:shardingsphere:classpath:sharding-tables.yaml
+
spring.shardingsphere.datasource.names=ds
spring.shardingsphere.datasource.ds.type=com.zaxxer.hikari.HikariDataSource
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-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/class-based-sharding-algorithm-example/class-based-sharding-spring-boot-jpa-example/src/main/resources/sharding-database [...]
new file mode 100644
index 00000000000..5ae3818e6cc
--- /dev/null
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-boot-jpa-example/src/main/resources/sharding-databases-tables.yaml
@@ -0,0 +1,87 @@
+#
+# 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_class_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_class_based
+ keyGenerateStrategy:
+ column: order_item_id
+ keyGeneratorName: snowflake
+ bindingTables:
+ - t_order,t_order_item
+ broadcastTables:
+ - t_address
+ defaultDatabaseStrategy:
+ standard:
+ shardingColumn: user_id
+ shardingAlgorithmName: database_class_based
+
+ shardingAlgorithms:
+ database_class_based:
+ type: CLASS_BASED
+ props:
+ strategy: standard
+ algorithmClassName: org.apache.shardingsphere.example.extension.classbased.sharding.spring.boot.jpa.fixture.ClassBasedDatabaseStandardShardingAlgorithmFixture
+ sharding-count: 2
+ t_order_class_based:
+ type: CLASS_BASED
+ props:
+ strategy: standard
+ algorithmClassName: org.apache.shardingsphere.example.extension.classbased.sharding.spring.boot.jpa.fixture.ClassBasedOrderStandardShardingAlgorithmFixture
+ sharding-count: 2
+ t_order_item_class_based:
+ type: CLASS_BASED
+ props:
+ strategy: standard
+ algorithmClassName: org.apache.shardingsphere.example.extension.classbased.sharding.spring.boot.jpa.fixture.ClassBasedOrderItemStandardShardingAlgorithmFixture
+ sharding-count: 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/class-based-sharding-algorithm-example/class-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/class-based-sharding-algorithm-example/class-based-sharding-spring-boot-jpa-example/src/main/resources/sharding-databases.yaml
new file mode 100644
index 00000000000..f291042bca0
--- /dev/null
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-boot-jpa-example/src/main/resources/sharding-databases.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
+ 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_class_based
+
+ shardingAlgorithms:
+ database_class_based:
+ type: CLASS_BASED
+ props:
+ strategy: standard
+ algorithmClassName: org.apache.shardingsphere.example.extension.classbased.sharding.spring.boot.jpa.fixture.ClassBasedDatabaseStandardShardingAlgorithmFixture
+ sharding-count: 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/class-based-sharding-algorithm-example/class-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/class-based-sharding-algorithm-example/class-based-sharding-spring-boot-jpa-example/src/main/resources/sharding-tables.yaml
new file mode 100644
index 00000000000..eaecb7f9f87
--- /dev/null
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-boot-jpa-example/src/main/resources/sharding-tables.yaml
@@ -0,0 +1,71 @@
+#
+# 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_class_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_class_based
+ keyGenerateStrategy:
+ column: order_item_id
+ keyGeneratorName: snowflake
+ bindingTables:
+ - t_order,t_order_item
+ broadcastTables:
+ - t_address
+
+ shardingAlgorithms:
+ t_order_class_based:
+ type: CLASS_BASED
+ props:
+ strategy: standard
+ algorithmClassName: org.apache.shardingsphere.example.extension.classbased.sharding.spring.boot.jpa.fixture.ClassBasedOrderStandardShardingAlgorithmFixture
+ sharding-count: 2
+ t_order_item_class_based:
+ type: CLASS_BASED
+ props:
+ strategy: standard
+ algorithmClassName: org.apache.shardingsphere.example.extension.classbased.sharding.spring.boot.jpa.fixture.ClassBasedOrderItemStandardShardingAlgorithmFixture
+ sharding-count: 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/class-based-sharding-algorithm-example/class-based-sharding-spring-boot-mybatis-example/pom.xml b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-boot-mybatis-example/pom.xml
index 6e5aeb0e77b..797e3fdd9a6 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-boot-mybatis-example/pom.xml
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-boot-mybatis-example/pom.xml
@@ -37,16 +37,12 @@
<dependency>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-jdbc-core-spring-boot-starter</artifactId>
+ <artifactId>shardingsphere-jdbc-core</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
</dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-test</artifactId>
- </dependency>
</dependencies>
</project>
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-boot-mybatis-example/src/main/java/org/apache/shardingsphere/example/extension/classbased/sharding/spring/boot/mybatis/fixture/ClassBasedDataSourceStandardShardingAlgorithmFixture.java b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/cl [...]
similarity index 95%
rename from examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-boot-mybatis-example/src/main/java/org/apache/shardingsphere/example/extension/classbased/sharding/spring/boot/mybatis/fixture/ClassBasedDataSourceStandardShardingAlgorithmFixture.java
rename to examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-boot-mybatis-example/src/main/java/org/apache/shardingsphere/example/extension/classbased/sharding/spring/boot/mybatis/fixture/ClassBasedDatabaseStandardShardingAlgorithmFixture.java
index 348e9aace66..c5b68866a21 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-boot-mybatis-example/src/main/java/org/apache/shardingsphere/example/extension/classbased/sharding/spring/boot/mybatis/fixture/ClassBasedDataSourceStandardShardingAlgorithmFixture.java
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-boot-mybatis-example/src/main/java/org/apache/shardingsphere/example/extension/classbased/sharding/spring/boot/mybatis/fixture/ClassBasedDatabaseStandardShardingAlgorithmFixture.java
@@ -27,7 +27,7 @@ import org.apache.shardingsphere.sharding.api.sharding.standard.StandardSharding
import java.util.Collection;
import java.util.Properties;
-public final class ClassBasedDataSourceStandardShardingAlgorithmFixture implements StandardShardingAlgorithm<Integer> {
+public final class ClassBasedDatabaseStandardShardingAlgorithmFixture implements StandardShardingAlgorithm<Integer> {
private static final String SHARDING_COUNT = "sharding-count";
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-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/class-based-sharding-algorithm-example/class-based-sharding-spring-boot-mybatis-example/src/main/r [...]
index 0c83e9814f7..4fb84cf4135 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-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/class-based-sharding-algorithm-example/class-based-sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-databases-tables.properties
@@ -15,6 +15,9 @@
# limitations under the License.
#
+spring.datasource.driver-class-name=org.apache.shardingsphere.driver.ShardingSphereDriver
+spring.datasource.url=jdbc:shardingsphere:classpath:sharding-databases-tables.yaml
+
spring.shardingsphere.mode.type=Standalone
spring.shardingsphere.mode.repository.type=JDBC
@@ -53,7 +56,7 @@ spring.shardingsphere.rules.sharding.tables.t_order_item.key-generate-strategy.k
spring.shardingsphere.rules.sharding.sharding-algorithms.datasource-class-based.type=CLASS_BASED
spring.shardingsphere.rules.sharding.sharding-algorithms.datasource-class-based.props.strategy=standard
-spring.shardingsphere.rules.sharding.sharding-algorithms.datasource-class-based.props.algorithmClassName=org.apache.shardingsphere.example.extension.classbased.sharding.spring.boot.mybatis.fixture.ClassBasedDataSourceStandardShardingAlgorithmFixture
+spring.shardingsphere.rules.sharding.sharding-algorithms.datasource-class-based.props.algorithmClassName=org.apache.shardingsphere.example.extension.classbased.sharding.spring.boot.mybatis.fixture.ClassBasedDatabaseStandardShardingAlgorithmFixture
spring.shardingsphere.rules.sharding.sharding-algorithms.datasource-class-based.props.sharding-count=2
spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-class-based.type=CLASS_BASED
spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-class-based.props.strategy=standard
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-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/class-based-sharding-algorithm-example/class-based-sharding-spring-boot-mybatis-example/src/main/resource [...]
index 628b859ddb7..c3a61cc66a5 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-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/class-based-sharding-algorithm-example/class-based-sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-databases.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://127.0.0.1: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://127.0.0.1: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-class-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-class-based.type=CLASS_BASED
-spring.shardingsphere.rules.sharding.sharding-algorithms.datasource-class-based.props.strategy=standard
-spring.shardingsphere.rules.sharding.sharding-algorithms.datasource-class-based.props.algorithmClassName=org.apache.shardingsphere.example.extension.classbased.sharding.spring.boot.mybatis.fixture.ClassBasedDataSourceStandardShardingAlgorithmFixture
-spring.shardingsphere.rules.sharding.sharding-algorithms.datasource-class-based.props.sharding-count=2
-
-spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE
-
-spring.shardingsphere.props.sql-show=true
-
+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/class-based-sharding-algorithm-example/class-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/class-based-sharding-algorithm-example/class-based-sharding-spring-boot-mybatis-example/src/main/resources/a [...]
index ac4ec5dfc97..4b6a1fe81b0 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-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/class-based-sharding-algorithm-example/class-based-sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-tables.properties
@@ -15,40 +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://127.0.0.1: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.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-class-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-class-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-class-based.type=CLASS_BASED
-spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-class-based.props.strategy=standard
-spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-class-based.props.algorithmClassName=org.apache.shardingsphere.example.extension.classbased.sharding.spring.boot.mybatis.fixture.ClassBasedOrderStandardShardingAlgorithmFixture
-spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-class-based.props.sharding-count=2
-spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-item-class-based.type=CLASS_BASED
-spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-item-class-based.props.strategy=standard
-spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-item-class-based.props.algorithmClassName=org.apache.shardingsphere.example.extension.classbased.sharding.spring.boot.mybatis.fixture.ClassBasedOrderItemStandardShardingAlgorithmFixture
-spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-item-class-based.props.sharding-count=2
-
-spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE
-
-spring.shardingsphere.props.sql-show=true
+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/class-based-sharding-algorithm-example/class-based-sharding-spring-boot-mybatis-example/src/main/resources/application.properties b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-boot-mybatis-example/src/main/resources/application.properties
index 7a990a2a16d..b04da2362cb 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-boot-mybatis-example/src/main/resources/application.properties
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-boot-mybatis-example/src/main/resources/application.properties
@@ -17,6 +17,6 @@
mybatis.config-location=classpath:META-INF/mybatis-config.xml
-spring.profiles.active=sharding-databases-tables
+#spring.profiles.active=sharding-databases-tables
#spring.profiles.active=sharding-tables
-#spring.profiles.active=sharding-databases
+spring.profiles.active=sharding-databases
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-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/class-based-sharding-algorithm-example/class-based-sharding-spring-boot-mybatis-example/src/main/resources/sharding- [...]
new file mode 100644
index 00000000000..813de1b2359
--- /dev/null
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-boot-mybatis-example/src/main/resources/sharding-databases-tables.yaml
@@ -0,0 +1,87 @@
+#
+# 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_class_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_class_based
+ keyGenerateStrategy:
+ column: order_item_id
+ keyGeneratorName: snowflake
+ bindingTables:
+ - t_order,t_order_item
+ broadcastTables:
+ - t_address
+ defaultDatabaseStrategy:
+ standard:
+ shardingColumn: user_id
+ shardingAlgorithmName: database_class_based
+
+ shardingAlgorithms:
+ database_class_based:
+ type: CLASS_BASED
+ props:
+ strategy: standard
+ algorithmClassName: org.apache.shardingsphere.example.extension.classbased.sharding.spring.boot.mybatis.fixture.ClassBasedDatabaseStandardShardingAlgorithmFixture
+ sharding-count: 2
+ t_order_class_based:
+ type: CLASS_BASED
+ props:
+ strategy: standard
+ algorithmClassName: org.apache.shardingsphere.example.extension.classbased.sharding.spring.boot.mybatis.fixture.ClassBasedOrderStandardShardingAlgorithmFixture
+ sharding-count: 2
+ t_order_item_class_based:
+ type: CLASS_BASED
+ props:
+ strategy: standard
+ algorithmClassName: org.apache.shardingsphere.example.extension.classbased.sharding.spring.boot.mybatis.fixture.ClassBasedOrderItemStandardShardingAlgorithmFixture
+ sharding-count: 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/class-based-sharding-algorithm-example/class-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/class-based-sharding-algorithm-example/class-based-sharding-spring-boot-mybatis-example/src/main/resources/sharding-databases.yaml
new file mode 100644
index 00000000000..358a9a5451e
--- /dev/null
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-boot-mybatis-example/src/main/resources/sharding-databases.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
+ 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_class_based
+
+ shardingAlgorithms:
+ database_class_based:
+ type: CLASS_BASED
+ props:
+ strategy: standard
+ algorithmClassName: org.apache.shardingsphere.example.extension.classbased.sharding.spring.boot.mybatis.fixture.ClassBasedDatabaseStandardShardingAlgorithmFixture
+ sharding-count: 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/class-based-sharding-algorithm-example/class-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/class-based-sharding-algorithm-example/class-based-sharding-spring-boot-mybatis-example/src/main/resources/sharding-tables.yaml
new file mode 100644
index 00000000000..c790b3714f8
--- /dev/null
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-boot-mybatis-example/src/main/resources/sharding-tables.yaml
@@ -0,0 +1,71 @@
+#
+# 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_class_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_class_based
+ keyGenerateStrategy:
+ column: order_item_id
+ keyGeneratorName: snowflake
+ bindingTables:
+ - t_order,t_order_item
+ broadcastTables:
+ - t_address
+
+ shardingAlgorithms:
+ t_order_class_based:
+ type: CLASS_BASED
+ props:
+ strategy: standard
+ algorithmClassName: org.apache.shardingsphere.example.extension.classbased.sharding.spring.boot.mybatis.fixture.ClassBasedOrderStandardShardingAlgorithmFixture
+ sharding-count: 2
+ t_order_item_class_based:
+ type: CLASS_BASED
+ props:
+ strategy: standard
+ algorithmClassName: org.apache.shardingsphere.example.extension.classbased.sharding.spring.boot.mybatis.fixture.ClassBasedOrderItemStandardShardingAlgorithmFixture
+ sharding-count: 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/class-based-sharding-algorithm-example/class-based-sharding-spring-namespace-jpa-example/pom.xml b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-namespace-jpa-example/pom.xml
index 885cabd0bb2..03329c87b8d 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-namespace-jpa-example/pom.xml
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-namespace-jpa-example/pom.xml
@@ -36,7 +36,11 @@
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-jdbc-core-spring-namespace</artifactId>
+ <artifactId>shardingsphere-jdbc-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
</dependencies>
</project>
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/extension/classbased/sharding/spring/namespace/jpa/ClassBasedShardingSpringNamespaceJpaExample.java b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-shard [...]
index 24f3188d4d7..a21fde6eb5c 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/extension/classbased/sharding/spring/namespace/jpa/ClassBasedShardingSpringNamespaceJpaExample.java
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/extension/classbased/sharding/spring/namespace/jpa/ClassBasedShardingSpringNamespaceJpaExample.java
@@ -27,8 +27,8 @@ import java.sql.SQLException;
public final class ClassBasedShardingSpringNamespaceJpaExample {
// private static final String CONFIG_FILE = "META-INF/application-sharding-databases.xml";
-// private static final String CONFIG_FILE = "META-INF/application-sharding-tables.xml";
- private static final String CONFIG_FILE = "META-INF/application-sharding-databases-tables.xml";
+ private static final String CONFIG_FILE = "META-INF/application-sharding-tables.xml";
+// private static final String CONFIG_FILE = "META-INF/application-sharding-databases-tables.xml";
public static void main(final String[] args) throws SQLException {
try (ConfigurableApplicationContext applicationContext = new ClassPathXmlApplicationContext(CONFIG_FILE)) {
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/extension/classbased/sharding/spring/namespace/jpa/fixture/ClassBasedDataSourceStandardShardingAlgorithmFixture.java b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/ [...]
similarity index 100%
rename from examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/extension/classbased/sharding/spring/namespace/jpa/fixture/ClassBasedDataSourceStandardShardingAlgorithmFixture.java
rename to examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-namespace-jpa-example/src/main/java/org/apache/shardingsphere/example/extension/classbased/sharding/spring/namespace/jpa/fixture/ClassBasedDatabaseStandardShardingAlgorithmFixture.java
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-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/class-based-sharding-algorithm-example/class-based-sharding-spring-namespace-jpa-example/src/ma [...]
index bc3a5d237fc..b40c36aedc6 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-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/class-based-sharding-algorithm-example/class-based-sharding-spring-namespace-jpa-example/src/main/resources/META-INF/application-sharding-databases-tables.xml
@@ -20,86 +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.jpa" />
- <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 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="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:standard-strategy id="databaseStrategy" sharding-column="user_id" algorithm-ref="databaseStrategyAlgorithm" />
- <sharding:standard-strategy id="orderTableStrategy" sharding-column="order_id" algorithm-ref="orderStrategyAlgorithm" />
- <sharding:standard-strategy id="orderItemTableStrategy" sharding-column="order_id" algorithm-ref="orderItemTableStrategyAlgorithm" />
-
- <sharding:sharding-algorithm id="databaseStrategyAlgorithm" type="CLASS_BASED">
- <props>
- <prop key="strategy">standard</prop>
- <prop key="algorithmClassName">org.apache.shardingsphere.example.extension.classbased.sharding.spring.namespace.jpa.fixture.ClassBasedDataSourceStandardShardingAlgorithmFixture</prop>
- <prop key="sharding-count">2</prop>
- </props>
- </sharding:sharding-algorithm>
- <sharding:sharding-algorithm id="orderStrategyAlgorithm" type="CLASS_BASED">
- <props>
- <prop key="strategy">standard</prop>
- <prop key="algorithmClassName">org.apache.shardingsphere.example.extension.classbased.sharding.spring.namespace.jpa.fixture.ClassBasedOrderStandardShardingAlgorithmFixture</prop>
- <prop key="sharding-count">2</prop>
- </props>
- </sharding:sharding-algorithm>
- <sharding:sharding-algorithm id="orderItemTableStrategyAlgorithm" type="CLASS_BASED">
- <props>
- <prop key="strategy">standard</prop>
- <prop key="algorithmClassName">org.apache.shardingsphere.example.extension.classbased.sharding.spring.namespace.jpa.fixture.ClassBasedOrderItemStandardShardingAlgorithmFixture</prop>
- <prop key="sharding-count">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_${0..1}.t_order_${0..1}" database-strategy-ref="databaseStrategy" table-strategy-ref="orderTableStrategy" key-generate-strategy-ref="orderKeyGenerator" />
- <sharding:table-rule logic-table="t_order_item" actual-data-nodes="demo_ds_${0..1}.t_order_item_${0..1}" database-strategy-ref="databaseStrategy" table-strategy-ref="orderItemTableStrategy" key-generate-strategy-ref="itemKeyGenerator" />
- </sharding:table-rules>
- <sharding: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>
-
<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/class-based-sharding-algorithm-example/class-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/class-based-sharding-algorithm-example/class-based-sharding-spring-namespace-jpa-example/src/main/reso [...]
index 200e5b78140..9f40158d780 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-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/class-based-sharding-algorithm-example/class-based-sharding-spring-namespace-jpa-example/src/main/resources/META-INF/application-sharding-databases.xml
@@ -20,65 +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.jpa" />
- <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 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="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:standard-strategy id="databaseStrategy" sharding-column="user_id" algorithm-ref="databaseAlgorithm" />
- <sharding:sharding-algorithm id="databaseAlgorithm" type="CLASS_BASED">
- <props>
- <prop key="strategy">standard</prop>
- <prop key="algorithmClassName">org.apache.shardingsphere.example.extension.classbased.sharding.spring.namespace.jpa.fixture.ClassBasedDataSourceStandardShardingAlgorithmFixture</prop>
- <prop key="sharding-count">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/class-based-sharding-algorithm-example/class-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/class-based-sharding-algorithm-example/class-based-sharding-spring-namespace-jpa-example/src/main/resourc [...]
index 3f0758d0878..8d29d0b1b40 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-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/class-based-sharding-algorithm-example/class-based-sharding-spring-namespace-jpa-example/src/main/resources/META-INF/application-sharding-tables.xml
@@ -20,71 +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.jpa" />
- <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="orderStrategyAlgorithm" />
- <sharding:standard-strategy id="orderItemTableStrategy" sharding-column="order_id" algorithm-ref="orderItemTableStrategyAlgorithm" />
-
- <sharding:sharding-algorithm id="orderStrategyAlgorithm" type="CLASS_BASED">
- <props>
- <prop key="strategy">standard</prop>
- <prop key="algorithmClassName">org.apache.shardingsphere.example.extension.classbased.sharding.spring.namespace.jpa.fixture.ClassBasedOrderStandardShardingAlgorithmFixture</prop>
- <prop key="sharding-count">2</prop>
- </props>
- </sharding:sharding-algorithm>
- <sharding:sharding-algorithm id="orderItemTableStrategyAlgorithm" type="CLASS_BASED">
- <props>
- <prop key="strategy">standard</prop>
- <prop key="algorithmClassName">org.apache.shardingsphere.example.extension.classbased.sharding.spring.namespace.jpa.fixture.ClassBasedOrderItemStandardShardingAlgorithmFixture</prop>
- <prop key="sharding-count">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>
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-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/class-based-sharding-algorithm-example/class-based-sharding-spring-namespace-jpa-example/src/main/resources/shardin [...]
new file mode 100644
index 00000000000..c16458ddfea
--- /dev/null
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-namespace-jpa-example/src/main/resources/sharding-databases-tables.yaml
@@ -0,0 +1,87 @@
+#
+# 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_class_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_class_based
+ keyGenerateStrategy:
+ column: order_item_id
+ keyGeneratorName: snowflake
+ bindingTables:
+ - t_order,t_order_item
+ broadcastTables:
+ - t_address
+ defaultDatabaseStrategy:
+ standard:
+ shardingColumn: user_id
+ shardingAlgorithmName: database_class_based
+
+ shardingAlgorithms:
+ database_class_based:
+ type: CLASS_BASED
+ props:
+ strategy: standard
+ algorithmClassName: org.apache.shardingsphere.example.extension.classbased.sharding.spring.namespace.jpa.fixture.ClassBasedDatabaseStandardShardingAlgorithmFixture
+ sharding-count: 2
+ t_order_class_based:
+ type: CLASS_BASED
+ props:
+ strategy: standard
+ algorithmClassName: org.apache.shardingsphere.example.extension.classbased.sharding.spring.namespace.jpa.fixture.ClassBasedOrderStandardShardingAlgorithmFixture
+ sharding-count: 2
+ t_order_item_class_based:
+ type: CLASS_BASED
+ props:
+ strategy: standard
+ algorithmClassName: org.apache.shardingsphere.example.extension.classbased.sharding.spring.namespace.jpa.fixture.ClassBasedOrderItemStandardShardingAlgorithmFixture
+ sharding-count: 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/class-based-sharding-algorithm-example/class-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/class-based-sharding-algorithm-example/class-based-sharding-spring-namespace-jpa-example/src/main/resources/sharding-datab [...]
new file mode 100644
index 00000000000..5b04506db4d
--- /dev/null
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-namespace-jpa-example/src/main/resources/sharding-databases.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
+ 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_class_based
+
+ shardingAlgorithms:
+ database_class_based:
+ type: CLASS_BASED
+ props:
+ strategy: standard
+ algorithmClassName: org.apache.shardingsphere.example.extension.classbased.sharding.spring.namespace.jpa.fixture.ClassBasedDatabaseStandardShardingAlgorithmFixture
+ sharding-count: 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/class-based-sharding-algorithm-example/class-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/class-based-sharding-algorithm-example/class-based-sharding-spring-namespace-jpa-example/src/main/resources/sharding-tables.yaml
new file mode 100644
index 00000000000..eaecb7f9f87
--- /dev/null
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-namespace-jpa-example/src/main/resources/sharding-tables.yaml
@@ -0,0 +1,71 @@
+#
+# 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_class_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_class_based
+ keyGenerateStrategy:
+ column: order_item_id
+ keyGeneratorName: snowflake
+ bindingTables:
+ - t_order,t_order_item
+ broadcastTables:
+ - t_address
+
+ shardingAlgorithms:
+ t_order_class_based:
+ type: CLASS_BASED
+ props:
+ strategy: standard
+ algorithmClassName: org.apache.shardingsphere.example.extension.classbased.sharding.spring.boot.jpa.fixture.ClassBasedOrderStandardShardingAlgorithmFixture
+ sharding-count: 2
+ t_order_item_class_based:
+ type: CLASS_BASED
+ props:
+ strategy: standard
+ algorithmClassName: org.apache.shardingsphere.example.extension.classbased.sharding.spring.boot.jpa.fixture.ClassBasedOrderItemStandardShardingAlgorithmFixture
+ sharding-count: 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/class-based-sharding-algorithm-example/class-based-sharding-spring-namespace-mybatis-example/pom.xml b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-namespace-mybatis-example/pom.xml
index 918576545d8..8e471b1e377 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-namespace-mybatis-example/pom.xml
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-namespace-mybatis-example/pom.xml
@@ -36,7 +36,7 @@
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-jdbc-core-spring-namespace</artifactId>
+ <artifactId>shardingsphere-jdbc-core</artifactId>
</dependency>
</dependencies>
</project>
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/extension/classbased/sharding/spring/namespace/mybatis/fixture/ClassBasedDataSourceStandardShardingAlgorithmFixture.java b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm- [...]
similarity index 95%
rename from examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/extension/classbased/sharding/spring/namespace/mybatis/fixture/ClassBasedDataSourceStandardShardingAlgorithmFixture.java
rename to examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/extension/classbased/sharding/spring/namespace/mybatis/fixture/ClassBasedDatabaseStandardShardingAlgorithmFixture.java
index d7bb4e3b0aa..b93286e15d2 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/extension/classbased/sharding/spring/namespace/mybatis/fixture/ClassBasedDataSourceStandardShardingAlgorithmFixture.java
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-namespace-mybatis-example/src/main/java/org/apache/shardingsphere/example/extension/classbased/sharding/spring/namespace/mybatis/fixture/ClassBasedDatabaseStandardShardingAlgorithmFixture.java
@@ -27,7 +27,7 @@ import org.apache.shardingsphere.sharding.api.sharding.standard.StandardSharding
import java.util.Collection;
import java.util.Properties;
-public final class ClassBasedDataSourceStandardShardingAlgorithmFixture implements StandardShardingAlgorithm<Integer> {
+public final class ClassBasedDatabaseStandardShardingAlgorithmFixture implements StandardShardingAlgorithm<Integer> {
private static final String SHARDING_COUNT = "sharding-count";
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-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/class-based-sharding-algorithm-example/class-based-sharding-spring-namespace-mybatis-exampl [...]
index 977c195dab6..607ab200f74 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-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/class-based-sharding-algorithm-example/class-based-sharding-spring-namespace-mybatis-example/src/main/resources/META-INF/application-sharding-databases-tables.xml
@@ -20,86 +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 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="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:standard-strategy id="databaseStrategy" sharding-column="user_id" algorithm-ref="databaseStrategyAlgorithm" />
- <sharding:standard-strategy id="orderTableStrategy" sharding-column="order_id" algorithm-ref="orderStrategyAlgorithm" />
- <sharding:standard-strategy id="orderItemTableStrategy" sharding-column="order_id" algorithm-ref="orderItemTableStrategyAlgorithm" />
-
- <sharding:sharding-algorithm id="databaseStrategyAlgorithm" type="CLASS_BASED">
- <props>
- <prop key="strategy">standard</prop>
- <prop key="algorithmClassName">org.apache.shardingsphere.example.extension.classbased.sharding.spring.namespace.mybatis.fixture.ClassBasedDataSourceStandardShardingAlgorithmFixture</prop>
- <prop key="sharding-count">2</prop>
- </props>
- </sharding:sharding-algorithm>
- <sharding:sharding-algorithm id="orderStrategyAlgorithm" type="CLASS_BASED">
- <props>
- <prop key="strategy">standard</prop>
- <prop key="algorithmClassName">org.apache.shardingsphere.example.extension.classbased.sharding.spring.namespace.mybatis.fixture.ClassBasedOrderStandardShardingAlgorithmFixture</prop>
- <prop key="sharding-count">2</prop>
- </props>
- </sharding:sharding-algorithm>
- <sharding:sharding-algorithm id="orderItemTableStrategyAlgorithm" type="CLASS_BASED">
- <props>
- <prop key="strategy">standard</prop>
- <prop key="algorithmClassName">org.apache.shardingsphere.example.extension.classbased.sharding.spring.namespace.mybatis.fixture.ClassBasedOrderItemStandardShardingAlgorithmFixture</prop>
- <prop key="sharding-count">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_${0..1}.t_order_${0..1}" database-strategy-ref="databaseStrategy" table-strategy-ref="orderTableStrategy" key-generate-strategy-ref="orderKeyGenerator" />
- <sharding:table-rule logic-table="t_order_item" actual-data-nodes="demo_ds_${0..1}.t_order_item_${0..1}" database-strategy-ref="databaseStrategy" table-strategy-ref="orderItemTableStrategy" key-generate-strategy-ref="itemKeyGenerator" />
- </sharding:table-rules>
- <sharding: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>
-
<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/class-based-sharding-algorithm-example/class-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/class-based-sharding-algorithm-example/class-based-sharding-spring-namespace-mybatis-example/src/m [...]
index 59f416cbf2e..03a293a0a19 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-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/class-based-sharding-algorithm-example/class-based-sharding-spring-namespace-mybatis-example/src/main/resources/META-INF/application-sharding-databases.xml
@@ -20,65 +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 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="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:standard-strategy id="databaseStrategy" sharding-column="user_id" algorithm-ref="databaseAlgorithm" />
- <sharding:sharding-algorithm id="databaseAlgorithm" type="CLASS_BASED">
- <props>
- <prop key="strategy">standard</prop>
- <prop key="algorithmClassName">org.apache.shardingsphere.example.extension.classbased.sharding.spring.namespace.mybatis.fixture.ClassBasedDataSourceStandardShardingAlgorithmFixture</prop>
- <prop key="sharding-count">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/class-based-sharding-algorithm-example/class-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/class-based-sharding-algorithm-example/class-based-sharding-spring-namespace-mybatis-example/src/main [...]
index 12c17e309d9..43b87c3e272 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-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/class-based-sharding-algorithm-example/class-based-sharding-spring-namespace-mybatis-example/src/main/resources/META-INF/application-sharding-tables.xml
@@ -20,71 +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" 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="orderStrategyAlgorithm" />
- <sharding:standard-strategy id="orderItemTableStrategy" sharding-column="order_id" algorithm-ref="orderItemTableStrategyAlgorithm" />
-
- <sharding:sharding-algorithm id="orderStrategyAlgorithm" type="CLASS_BASED">
- <props>
- <prop key="strategy">standard</prop>
- <prop key="algorithmClassName">org.apache.shardingsphere.example.extension.classbased.sharding.spring.namespace.mybatis.fixture.ClassBasedOrderStandardShardingAlgorithmFixture</prop>
- <prop key="sharding-count">2</prop>
- </props>
- </sharding:sharding-algorithm>
- <sharding:sharding-algorithm id="orderItemTableStrategyAlgorithm" type="CLASS_BASED">
- <props>
- <prop key="strategy">standard</prop>
- <prop key="algorithmClassName">org.apache.shardingsphere.example.extension.classbased.sharding.spring.namespace.mybatis.fixture.ClassBasedOrderItemStandardShardingAlgorithmFixture</prop>
- <prop key="sharding-count">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>
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-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/class-based-sharding-algorithm-example/class-based-sharding-spring-namespace-mybatis-example/src/main/resources [...]
new file mode 100644
index 00000000000..c762a510c2a
--- /dev/null
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-namespace-mybatis-example/src/main/resources/sharding-databases-tables.yaml
@@ -0,0 +1,87 @@
+#
+# 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_class_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_class_based
+ keyGenerateStrategy:
+ column: order_item_id
+ keyGeneratorName: snowflake
+ bindingTables:
+ - t_order,t_order_item
+ broadcastTables:
+ - t_address
+ defaultDatabaseStrategy:
+ standard:
+ shardingColumn: user_id
+ shardingAlgorithmName: database_class_based
+
+ shardingAlgorithms:
+ database_class_based:
+ type: CLASS_BASED
+ props:
+ strategy: standard
+ algorithmClassName: org.apache.shardingsphere.example.extension.classbased.sharding.spring.namespace.mybatis.fixture.ClassBasedDatabaseStandardShardingAlgorithmFixture
+ sharding-count: 2
+ t_order_class_based:
+ type: CLASS_BASED
+ props:
+ strategy: standard
+ algorithmClassName: org.apache.shardingsphere.example.extension.classbased.sharding.spring.namespace.mybatis.fixture.ClassBasedOrderStandardShardingAlgorithmFixture
+ sharding-count: 2
+ t_order_item_class_based:
+ type: CLASS_BASED
+ props:
+ strategy: standard
+ algorithmClassName: org.apache.shardingsphere.example.extension.classbased.sharding.spring.namespace.mybatis.fixture.ClassBasedOrderItemStandardShardingAlgorithmFixture
+ sharding-count: 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/class-based-sharding-algorithm-example/class-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/class-based-sharding-algorithm-example/class-based-sharding-spring-namespace-mybatis-example/src/main/resources/shardi [...]
new file mode 100644
index 00000000000..4defb4b86d0
--- /dev/null
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-namespace-mybatis-example/src/main/resources/sharding-databases.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
+ 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_class_based
+
+ shardingAlgorithms:
+ database_class_based:
+ type: CLASS_BASED
+ props:
+ strategy: standard
+ algorithmClassName: org.apache.shardingsphere.example.extension.classbased.sharding.spring.namespace.mybatis.fixture.ClassBasedDatabaseStandardShardingAlgorithmFixture
+ sharding-count: 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/class-based-sharding-algorithm-example/class-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/class-based-sharding-algorithm-example/class-based-sharding-spring-namespace-mybatis-example/src/main/resources/sharding- [...]
new file mode 100644
index 00000000000..00638986820
--- /dev/null
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/class-based-sharding-algorithm-example/class-based-sharding-spring-namespace-mybatis-example/src/main/resources/sharding-tables.yaml
@@ -0,0 +1,71 @@
+#
+# 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_class_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_class_based
+ keyGenerateStrategy:
+ column: order_item_id
+ keyGeneratorName: snowflake
+ bindingTables:
+ - t_order,t_order_item
+ broadcastTables:
+ - t_address
+
+ shardingAlgorithms:
+ t_order_class_based:
+ type: CLASS_BASED
+ props:
+ strategy: standard
+ algorithmClassName: org.apache.shardingsphere.example.extension.classbased.sharding.spring.namespace.mybatis.fixture.ClassBasedOrderStandardShardingAlgorithmFixture
+ sharding-count: 2
+ t_order_item_class_based:
+ type: CLASS_BASED
+ props:
+ strategy: standard
+ algorithmClassName: org.apache.shardingsphere.example.extension.classbased.sharding.spring.namespace.mybatis.fixture.ClassBasedOrderItemStandardShardingAlgorithmFixture
+ sharding-count: 2
+
+ keyGenerators:
+ snowflake:
+ type: SNOWFLAKE
+
+props:
+ spl-show: true