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/29 16:42:35 UTC
[shardingsphere] branch master updated: Remove Spring in sharding example (#22513)
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 935a8108a6e Remove Spring in sharding example (#22513)
935a8108a6e is described below
commit 935a8108a6e411cab79c7861fe1d7315d27f941c
Author: ChenJiaHao <37...@users.noreply.github.com>
AuthorDate: Wed Nov 30 00:42:18 2022 +0800
Remove Spring in sharding example (#22513)
---
.../sharding-spring-boot-jpa-example/pom.xml | 2 +-
.../application-sharding-auto-tables.properties | 43 +---------
...pplication-sharding-databases-tables.properties | 55 +------------
.../application-sharding-databases.properties | 39 +--------
.../application-sharding-tables.properties | 44 +---------
.../src/main/resources/application.properties | 4 +-
.../src/main/resources/sharding-auto-tables.yaml | 72 ++++++++++++++++
.../main/resources/sharding-databases-tables.yaml | 93 +++++++++++++++++++++
.../src/main/resources/sharding-databases.yaml | 67 +++++++++++++++
.../src/main/resources/sharding-tables.yaml | 78 ++++++++++++++++++
.../sharding-spring-boot-mybatis-example/pom.xml | 2 +-
.../application-sharding-auto-tables.properties | 43 +---------
...pplication-sharding-databases-tables.properties | 46 +----------
.../application-sharding-databases.properties | 35 +-------
.../application-sharding-tables.properties | 35 +-------
.../src/main/resources/application.properties | 4 +-
.../src/main/resources/sharding-auto-tables.yaml | 72 ++++++++++++++++
.../main/resources/sharding-databases-tables.yaml | 78 ++++++++++++++++++
.../src/main/resources/sharding-databases.yaml | 62 ++++++++++++++
.../src/main/resources/sharding-tables.yaml | 64 +++++++++++++++
.../sharding-spring-namespace-jpa-example/pom.xml | 2 +-
.../application-sharding-databases-tables.xml | 80 +-----------------
.../META-INF/application-sharding-databases.xml | 53 +-----------
.../META-INF/application-sharding-tables.xml | 60 +-------------
.../main/resources/sharding-databases-tables.yaml | 96 ++++++++++++++++++++++
.../src/main/resources/sharding-databases.yaml | 67 +++++++++++++++
.../src/main/resources/sharding-tables.yaml | 77 +++++++++++++++++
.../pom.xml | 2 +-
.../application-sharding-databases-tables.xml | 66 +--------------
.../META-INF/application-sharding-databases.xml | 50 +----------
.../META-INF/application-sharding-tables.xml | 53 +-----------
.../main/resources/sharding-databases-tables.yaml | 81 ++++++++++++++++++
.../src/main/resources/sharding-databases.yaml | 62 ++++++++++++++
.../src/main/resources/sharding-tables.yaml | 67 +++++++++++++++
34 files changed, 1079 insertions(+), 675 deletions(-)
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-jpa-example/pom.xml b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-jpa-example/pom.xml
index 603d0be269e..61f13907e38 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-jpa-example/pom.xml
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-jpa-example/pom.xml
@@ -36,7 +36,7 @@
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-jdbc-core-spring-boot-starter</artifactId>
+ <artifactId>shardingsphere-jdbc-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-jpa-example/src/main/resources/application-sharding-auto-tables.properties b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-jpa-example/src/main/resources/application-sharding-auto-tables.properties
index 0a72127672a..0e64cb7cbf7 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-jpa-example/src/main/resources/application-sharding-auto-tables.properties
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-jpa-example/src/main/resources/application-sharding-auto-tables.properties
@@ -15,44 +15,5 @@
# limitations under the License.
#
-spring.shardingsphere.datasource.names=ds-0,ds-1
-
-spring.shardingsphere.datasource.ds-0.jdbc-url=jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
-spring.shardingsphere.datasource.ds-0.type=com.zaxxer.hikari.HikariDataSource
-spring.shardingsphere.datasource.ds-0.driver-class-name=com.mysql.jdbc.Driver
-spring.shardingsphere.datasource.ds-0.username=root
-spring.shardingsphere.datasource.ds-0.password=
-
-spring.shardingsphere.datasource.ds-1.jdbc-url=jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
-spring.shardingsphere.datasource.ds-1.type=com.zaxxer.hikari.HikariDataSource
-spring.shardingsphere.datasource.ds-1.driver-class-name=com.mysql.jdbc.Driver
-spring.shardingsphere.datasource.ds-1.username=root
-spring.shardingsphere.datasource.ds-1.password=
-
-spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-column=user_id
-spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-algorithm-name=database-inline
-spring.shardingsphere.rules.sharding.binding-tables[0]=t_order,t_order_item
-
-spring.shardingsphere.rules.sharding.autotables.t_order.actual-datasources=ds-${0..1}
-
-spring.shardingsphere.rules.sharding.auto-tables.t_order.sharding-strategy.standard.sharding-column=order_id
-spring.shardingsphere.rules.sharding.auto-tables.t_order.sharding-strategy.standard.sharding-algorithm-name=auto-mod
-
-spring.shardingsphere.rules.sharding.auto-tables.t_order.key-generate-strategy.column=order_id
-spring.shardingsphere.rules.sharding.auto-tables.t_order.key-generate-strategy.key-generator-name=snowflake
-
-spring.shardingsphere.rules.sharding.auto-tables.t_order_item.actual-datasources=ds-${0..1}
-
-spring.shardingsphere.rules.sharding.auto-tables.t_order_item.sharding-strategy.standard.sharding-column=order_item_id
-spring.shardingsphere.rules.sharding.auto-tables.t_order_item.sharding-strategy.standard.sharding-algorithm-name=auto-mod
-
-spring.shardingsphere.rules.sharding.auto-tables.t_order_item.key-generate-strategy.column=order_item_id
-spring.shardingsphere.rules.sharding.auto-tables.t_order_item.key-generate-strategy.key-generator-name=snowflake
-
-spring.shardingsphere.rules.sharding.sharding-algorithms.database-inline.type=INLINE
-spring.shardingsphere.rules.sharding.sharding-algorithms.database-inline.props.algorithm-expression=ds-$->{user_id % 2}
-
-spring.shardingsphere.rules.sharding.sharding-algorithms.auto-mod.type=mod
-spring.shardingsphere.rules.sharding.sharding-algorithms.auto-mod.props.sharding-count=4
-
-spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE
+spring.datasource.driver-class-name=org.apache.shardingsphere.driver.ShardingSphereDriver
+spring.datasource.url=jdbc:shardingsphere:classpath:sharding-auto-tables.yaml
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-jpa-example/src/main/resources/application-sharding-databases-tables.properties b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-jpa-example/src/main/resources/application-sharding-databases-tables.properties
index c1531090419..12969865b87 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-jpa-example/src/main/resources/application-sharding-databases-tables.properties
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-jpa-example/src/main/resources/application-sharding-databases-tables.properties
@@ -15,56 +15,5 @@
# limitations under the License.
#
-spring.shardingsphere.datasource.names=ds-0,ds-1
-
-spring.shardingsphere.datasource.ds-0.jdbc-url=jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
-spring.shardingsphere.datasource.ds-0.type=com.zaxxer.hikari.HikariDataSource
-spring.shardingsphere.datasource.ds-0.driver-class-name=com.mysql.jdbc.Driver
-spring.shardingsphere.datasource.ds-0.username=root
-spring.shardingsphere.datasource.ds-0.password=
-spring.shardingsphere.datasource.ds-0.max-active=16
-
-spring.shardingsphere.datasource.ds-1.jdbc-url=jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
-spring.shardingsphere.datasource.ds-1.type=com.zaxxer.hikari.HikariDataSource
-spring.shardingsphere.datasource.ds-1.driver-class-name=com.mysql.jdbc.Driver
-spring.shardingsphere.datasource.ds-1.username=root
-spring.shardingsphere.datasource.ds-1.password=
-spring.shardingsphere.datasource.ds-1.max-active=16
-
-spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-column=user_id
-spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-algorithm-name=database-inline
-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-inline
-
-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-inline
-
-spring.shardingsphere.rules.sharding.tables.t_order_item.key-generate-strategy.column=order_item_id
-spring.shardingsphere.rules.sharding.tables.t_order_item.key-generate-strategy.key-generator-name=snowflake
-
-spring.shardingsphere.rules.sharding.tables.t_account.actual-data-nodes=ds-$->{0..1}.t_account_$->{0..1}
-spring.shardingsphere.rules.sharding.tables.t_account.table-strategy.standard.sharding-algorithm-name=t-account-inline
-
-spring.shardingsphere.rules.sharding.tables.t_account.key-generate-strategy.column=account_id
-spring.shardingsphere.rules.sharding.tables.t_account.key-generate-strategy.key-generator-name=snowflake
-
-spring.shardingsphere.rules.sharding.default-sharding-column=account_id
-
-spring.shardingsphere.rules.sharding.sharding-algorithms.database-inline.type=INLINE
-spring.shardingsphere.rules.sharding.sharding-algorithms.database-inline.props.algorithm-expression=ds-$->{user_id % 2}
-spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-inline.type=INLINE
-spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-inline.props.algorithm-expression=t_order_$->{order_id % 2}
-spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-item-inline.type=INLINE
-spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-item-inline.props.algorithm-expression=t_order_item_$->{order_id % 2}
-spring.shardingsphere.rules.sharding.sharding-algorithms.t-account-inline.type=INLINE
-spring.shardingsphere.rules.sharding.sharding-algorithms.t-account-inline.props.algorithm-expression=t_account_$->{account_id % 2}
-
-spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE
+spring.datasource.driver-class-name=org.apache.shardingsphere.driver.ShardingSphereDriver
+spring.datasource.url=jdbc:shardingsphere:classpath:sharding-databases-tables.yaml
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-jpa-example/src/main/resources/application-sharding-databases.properties b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-jpa-example/src/main/resources/application-sharding-databases.properties
index 62b0ad2019a..73c5ae7685e 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-jpa-example/src/main/resources/application-sharding-databases.properties
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-jpa-example/src/main/resources/application-sharding-databases.properties
@@ -15,41 +15,6 @@
# limitations under the License.
#
-spring.shardingsphere.datasource.names=ds-0,ds-1
+spring.datasource.driver-class-name=org.apache.shardingsphere.driver.ShardingSphereDriver
+spring.datasource.url=jdbc:shardingsphere:classpath:sharding-databases.yaml
-spring.shardingsphere.datasource.ds-0.jdbc-url=jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
-spring.shardingsphere.datasource.ds-0.type=com.zaxxer.hikari.HikariDataSource
-spring.shardingsphere.datasource.ds-0.driver-class-name=com.mysql.jdbc.Driver
-spring.shardingsphere.datasource.ds-0.username=root
-spring.shardingsphere.datasource.ds-0.password=
-
-spring.shardingsphere.datasource.ds-1.jdbc-url=jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
-spring.shardingsphere.datasource.ds-1.type=com.zaxxer.hikari.HikariDataSource
-spring.shardingsphere.datasource.ds-1.driver-class-name=com.mysql.jdbc.Driver
-spring.shardingsphere.datasource.ds-1.username=root
-spring.shardingsphere.datasource.ds-1.password=
-
-spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-column=user_id
-spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-algorithm-name=database-inline
-spring.shardingsphere.rules.sharding.binding-tables[0]=t_order,t_order_item
-spring.shardingsphere.rules.sharding.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.tables.t_account.actual-data-nodes=ds-$->{0..1}.t_account
-
-spring.shardingsphere.rules.sharding.tables.t_account.key-generate-strategy.column=account_id
-spring.shardingsphere.rules.sharding.tables.t_account.key-generate-strategy.key-generator-name=snowflake
-
-spring.shardingsphere.rules.sharding.sharding-algorithms.database-inline.type=INLINE
-spring.shardingsphere.rules.sharding.sharding-algorithms.database-inline.props.algorithm-expression=ds-$->{user_id % 2}
-
-spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-jpa-example/src/main/resources/application-sharding-tables.properties b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-jpa-example/src/main/resources/application-sharding-tables.properties
index 01d11ffd932..4b6a1fe81b0 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-jpa-example/src/main/resources/application-sharding-tables.properties
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-jpa-example/src/main/resources/application-sharding-tables.properties
@@ -15,45 +15,5 @@
# limitations under the License.
#
-spring.shardingsphere.datasource.names=ds
-
-spring.shardingsphere.datasource.ds.type=com.zaxxer.hikari.HikariDataSource
-spring.shardingsphere.datasource.ds.driver-class-name=com.mysql.jdbc.Driver
-spring.shardingsphere.datasource.ds.jdbc-url=jdbc:mysql://localhost:3306/demo_ds?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
-spring.shardingsphere.datasource.ds.username=root
-spring.shardingsphere.datasource.ds.password=
-spring.shardingsphere.datasource.ds.max-active=16
-
-spring.shardingsphere.rules.sharding.tables.t_order.actual-data-nodes=ds.t_order_$->{0..1}
-spring.shardingsphere.rules.sharding.tables.t_order.table-strategy.standard.sharding-column=order_id
-spring.shardingsphere.rules.sharding.tables.t_order.table-strategy.standard.sharding-algorithm-name=t-order-inline
-
-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-inline
-
-spring.shardingsphere.rules.sharding.tables.t_order_item.key-generate-strategy.column=order_item_id
-spring.shardingsphere.rules.sharding.tables.t_order_item.key-generate-strategy.key-generator-name=snowflake
-
-spring.shardingsphere.rules.sharding.tables.t_account.actual-data-nodes=ds.t_account_$->{0..1}
-spring.shardingsphere.rules.sharding.tables.t_account.table-strategy.standard.sharding-algorithm-name=t-account-inline
-
-spring.shardingsphere.rules.sharding.default-sharding-column=account_id
-
-spring.shardingsphere.rules.sharding.tables.t_account.key-generate-strategy.column=account_id
-spring.shardingsphere.rules.sharding.tables.t_account.key-generate-strategy.key-generator-name=snowflake
-
-spring.shardingsphere.rules.sharding.binding-tables[0]=t_order,t_order_item
-spring.shardingsphere.rules.sharding.broadcast-tables=t_address
-
-spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-inline.type=INLINE
-spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-inline.props.algorithm-expression=t_order_$->{order_id % 2}
-spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-item-inline.type=INLINE
-spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-item-inline.props.algorithm-expression=t_order_item_$->{order_id % 2}
-spring.shardingsphere.rules.sharding.sharding-algorithms.t-account-inline.type=INLINE
-spring.shardingsphere.rules.sharding.sharding-algorithms.t-account-inline.props.algorithm-expression=t_account_$->{account_id % 2}
-
-spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE
+spring.datasource.driver-class-name=org.apache.shardingsphere.driver.ShardingSphereDriver
+spring.datasource.url=jdbc:shardingsphere:classpath:sharding-tables.yaml
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-jpa-example/src/main/resources/application.properties b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-jpa-example/src/main/resources/application.properties
index 089beafcac9..d78ddd8d88d 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-jpa-example/src/main/resources/application.properties
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-jpa-example/src/main/resources/application.properties
@@ -20,6 +20,6 @@ spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
spring.jpa.properties.hibernate.show_sql=false
#spring.profiles.active=sharding-databases
-#spring.profiles.active=sharding-tables
+spring.profiles.active=sharding-tables
#spring.profiles.active=sharding-databases-tables
-spring.profiles.active=sharding-auto-tables
+#spring.profiles.active=sharding-auto-tables
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-jpa-example/src/main/resources/sharding-auto-tables.yaml b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-jpa-example/src/main/resources/sharding-auto-tables.yaml
new file mode 100644
index 00000000000..22101c6f3e9
--- /dev/null
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-jpa-example/src/main/resources/sharding-auto-tables.yaml
@@ -0,0 +1,72 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+dataSources:
+ ds-0:
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ jdbcUrl: jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+ username: root
+ password:
+ ds-1:
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ jdbcUrl: jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+ username: root
+ password:
+
+rules:
+- !SHARDING
+ autoTables:
+ t_order:
+ actualDataSources: ds-${0..1}
+ shardingStrategy:
+ standard:
+ shardingColumn: order_id
+ shardingAlgorithmName: auto-mod
+ keyGenerateStrategy:
+ column: order_id
+ keyGeneratorName: snowflake
+ t_order_item:
+ actualDataSources: ds-${0..1}
+ shardingStrategy:
+ standard:
+ shardingColumn: order_item_id
+ shardingAlgorithmName: auto-mod
+ keyGenerateStrategy:
+ column: order_item_id
+ keyGeneratorName: snowflake
+ bindingTables:
+ - t_order,t_order_item
+ defaultDatabaseStrategy:
+ standard:
+ shardingColumn: user_id
+ shardingAlgorithmName: database-inline
+
+ shardingAlgorithms:
+ database-inline:
+ type: INLINE
+ props:
+ algorithm-expression: ds-$->{user_id % 2}
+ auto-mod:
+ type: MOD
+ props:
+ sharding-count: 4
+
+ keyGenerators:
+ snowflake:
+ type: SNOWFLAKE
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-jpa-example/src/main/resources/sharding-databases-tables.yaml b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-jpa-example/src/main/resources/sharding-databases-tables.yaml
new file mode 100644
index 00000000000..0ae122f3092
--- /dev/null
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-jpa-example/src/main/resources/sharding-databases-tables.yaml
@@ -0,0 +1,93 @@
+#
+# 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:
+ maxActive: 16
+ 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:
+ maxActive: 16
+
+rules:
+- !SHARDING
+ tables:
+ t_order:
+ actualDataNodes: ds-$->{0..1}.t_order_$->{0..1}
+ tableStrategy:
+ standard:
+ shardingColumn: order_id
+ shardingAlgorithmName: t-order-inline
+ 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-inline
+ keyGenerateStrategy:
+ column: order_item_id
+ keyGeneratorName: snowflake
+ t_account:
+ actualDataNodes: ds-$->{0..1}.t_account_$->{0..1}
+ tableStrategy:
+ standard:
+ shardingAlgorithmName: t-account-inline
+ keyGenerateStrategy:
+ column: account_id
+ keyGeneratorName: snowflake
+ bindingTables:
+ - t_order,t_order_item
+ broadcastTables:
+ - t_address
+ defaultShardingColumn: account_id
+ defaultDatabaseStrategy:
+ standard:
+ shardingColumn: user_id
+ shardingAlgorithmName: database-inline
+
+ shardingAlgorithms:
+ database-inline:
+ type: INLINE
+ props:
+ algorithm-expression: ds-$->{user_id % 2}
+ t-order-inline:
+ type: INLINE
+ props:
+ algorithm-expression: t_order_$->{order_id % 2}
+ t-order-item-inline:
+ type: INLINE
+ props:
+ algorithm-expression: t_order_item_$->{order_id % 2}
+ t-account-inline:
+ type: INLINE
+ props:
+ algorithm-expression: t_account_$->{account_id % 2}
+
+ keyGenerators:
+ snowflake:
+ type: SNOWFLAKE
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-jpa-example/src/main/resources/sharding-databases.yaml b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-jpa-example/src/main/resources/sharding-databases.yaml
new file mode 100644
index 00000000000..5193333a1c6
--- /dev/null
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/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
+ t_account:
+ actualDataNodes: ds-${0..1}.t_account
+ keyGenerateStrategy:
+ column: account_id
+ keyGeneratorName: snowflake
+ bindingTables:
+ - t_order,t_order_item
+ broadcastTables:
+ - t_address
+ defaultDatabaseStrategy:
+ standard:
+ shardingColumn: user_id
+ shardingAlgorithmName: database-inline
+
+ shardingAlgorithms:
+ database-inline:
+ type: INLINE
+ props:
+ algorithm-expression: ds-$->{user_id % 2}
+
+ keyGenerators:
+ snowflake:
+ type: SNOWFLAKE
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-jpa-example/src/main/resources/sharding-tables.yaml b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-jpa-example/src/main/resources/sharding-tables.yaml
new file mode 100644
index 00000000000..0d04aff6608
--- /dev/null
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-jpa-example/src/main/resources/sharding-tables.yaml
@@ -0,0 +1,78 @@
+#
+# 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:
+ maxActive: 16
+
+rules:
+- !SHARDING
+ tables:
+ t_order:
+ actualDataNodes: ds.t_order_$->{0..1}
+ tableStrategy:
+ standard:
+ shardingColumn: order_id
+ shardingAlgorithmName: t-order-inline
+ keyGenerateStrategy:
+ column: order_id
+ keyGeneratorName: snowflake
+ t_order_item:
+ actualDataNodes: ds.t_order_item_$->{0..1}
+ tableStrategy:
+ standard:
+ shardingColumn: order_id
+ shardingAlgorithmName: t-order-item-inline
+ keyGenerateStrategy:
+ column: order_item_id
+ keyGeneratorName: snowflake
+ t_account:
+ actualDataNodes: ds.t_account_$->{0..1}
+ tableStrategy:
+ standard:
+ shardingAlgorithmName: t-account-inline
+ keyGenerateStrategy:
+ column: account_id
+ keyGeneratorName: snowflake
+ defaultShardingColumn: account_id
+ bindingTables:
+ - t_order,t_order_item
+ broadcastTables:
+ - t_address
+
+ shardingAlgorithms:
+ t-order-inline:
+ type: INLINE
+ props:
+ algorithm-expression: t_order_$->{order_id % 2}
+ t-order-item-inline:
+ type: INLINE
+ props:
+ algorithm-expression: t_order_item_$->{order_id % 2}
+ t-account-inline:
+ type: INLINE
+ props:
+ algorithm-expression: t_account_$->{account_id % 2}
+
+ keyGenerators:
+ snowflake:
+ type: SNOWFLAKE
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/pom.xml b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/pom.xml
index 0a2d2a1125a..3779399535c 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/pom.xml
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/pom.xml
@@ -37,7 +37,7 @@
<dependency>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-jdbc-core-spring-boot-starter</artifactId>
+ <artifactId>shardingsphere-jdbc-core</artifactId>
</dependency>
<dependency>
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-auto-tables.properties b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-auto-tables.properties
index 0a72127672a..0e64cb7cbf7 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-auto-tables.properties
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-auto-tables.properties
@@ -15,44 +15,5 @@
# limitations under the License.
#
-spring.shardingsphere.datasource.names=ds-0,ds-1
-
-spring.shardingsphere.datasource.ds-0.jdbc-url=jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
-spring.shardingsphere.datasource.ds-0.type=com.zaxxer.hikari.HikariDataSource
-spring.shardingsphere.datasource.ds-0.driver-class-name=com.mysql.jdbc.Driver
-spring.shardingsphere.datasource.ds-0.username=root
-spring.shardingsphere.datasource.ds-0.password=
-
-spring.shardingsphere.datasource.ds-1.jdbc-url=jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
-spring.shardingsphere.datasource.ds-1.type=com.zaxxer.hikari.HikariDataSource
-spring.shardingsphere.datasource.ds-1.driver-class-name=com.mysql.jdbc.Driver
-spring.shardingsphere.datasource.ds-1.username=root
-spring.shardingsphere.datasource.ds-1.password=
-
-spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-column=user_id
-spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-algorithm-name=database-inline
-spring.shardingsphere.rules.sharding.binding-tables[0]=t_order,t_order_item
-
-spring.shardingsphere.rules.sharding.autotables.t_order.actual-datasources=ds-${0..1}
-
-spring.shardingsphere.rules.sharding.auto-tables.t_order.sharding-strategy.standard.sharding-column=order_id
-spring.shardingsphere.rules.sharding.auto-tables.t_order.sharding-strategy.standard.sharding-algorithm-name=auto-mod
-
-spring.shardingsphere.rules.sharding.auto-tables.t_order.key-generate-strategy.column=order_id
-spring.shardingsphere.rules.sharding.auto-tables.t_order.key-generate-strategy.key-generator-name=snowflake
-
-spring.shardingsphere.rules.sharding.auto-tables.t_order_item.actual-datasources=ds-${0..1}
-
-spring.shardingsphere.rules.sharding.auto-tables.t_order_item.sharding-strategy.standard.sharding-column=order_item_id
-spring.shardingsphere.rules.sharding.auto-tables.t_order_item.sharding-strategy.standard.sharding-algorithm-name=auto-mod
-
-spring.shardingsphere.rules.sharding.auto-tables.t_order_item.key-generate-strategy.column=order_item_id
-spring.shardingsphere.rules.sharding.auto-tables.t_order_item.key-generate-strategy.key-generator-name=snowflake
-
-spring.shardingsphere.rules.sharding.sharding-algorithms.database-inline.type=INLINE
-spring.shardingsphere.rules.sharding.sharding-algorithms.database-inline.props.algorithm-expression=ds-$->{user_id % 2}
-
-spring.shardingsphere.rules.sharding.sharding-algorithms.auto-mod.type=mod
-spring.shardingsphere.rules.sharding.sharding-algorithms.auto-mod.props.sharding-count=4
-
-spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE
+spring.datasource.driver-class-name=org.apache.shardingsphere.driver.ShardingSphereDriver
+spring.datasource.url=jdbc:shardingsphere:classpath:sharding-auto-tables.yaml
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-databases-tables.properties b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-databases-tables.properties
index 5d1c5b73e7e..12969865b87 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-databases-tables.properties
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-databases-tables.properties
@@ -15,47 +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://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
-spring.shardingsphere.datasource.ds-0.type=com.zaxxer.hikari.HikariDataSource
-spring.shardingsphere.datasource.ds-0.driver-class-name=com.mysql.jdbc.Driver
-spring.shardingsphere.datasource.ds-0.username=root
-spring.shardingsphere.datasource.ds-0.password=
-
-spring.shardingsphere.datasource.ds-1.jdbc-url=jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
-spring.shardingsphere.datasource.ds-1.type=com.zaxxer.hikari.HikariDataSource
-spring.shardingsphere.datasource.ds-1.driver-class-name=com.mysql.jdbc.Driver
-spring.shardingsphere.datasource.ds-1.username=root
-spring.shardingsphere.datasource.ds-1.password=
-
-spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-column=user_id
-spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-algorithm-name=database-inline
-spring.shardingsphere.rules.sharding.binding-tables[0]=t_order,t_order_item
-spring.shardingsphere.rules.sharding.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-inline
-
-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-inline
-
-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.database-inline.type=INLINE
-spring.shardingsphere.rules.sharding.sharding-algorithms.database-inline.props.algorithm-expression=ds-$->{user_id % 2}
-spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-inline.type=INLINE
-spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-inline.props.algorithm-expression=t_order_$->{order_id % 2}
-spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-item-inline.type=INLINE
-spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-item-inline.props.algorithm-expression=t_order_item_$->{order_id % 2}
-
-spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE
+spring.datasource.driver-class-name=org.apache.shardingsphere.driver.ShardingSphereDriver
+spring.datasource.url=jdbc:shardingsphere:classpath:sharding-databases-tables.yaml
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-databases.properties b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-databases.properties
index 1630ddc75b2..c3a61cc66a5 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-databases.properties
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-databases.properties
@@ -15,36 +15,5 @@
# limitations under the License.
#
-spring.shardingsphere.datasource.names=ds-0,ds-1
-
-spring.shardingsphere.datasource.ds-0.jdbc-url=jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
-spring.shardingsphere.datasource.ds-0.type=com.zaxxer.hikari.HikariDataSource
-spring.shardingsphere.datasource.ds-0.driver-class-name=com.mysql.jdbc.Driver
-spring.shardingsphere.datasource.ds-0.username=root
-spring.shardingsphere.datasource.ds-0.password=
-
-spring.shardingsphere.datasource.ds-1.jdbc-url=jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
-spring.shardingsphere.datasource.ds-1.type=com.zaxxer.hikari.HikariDataSource
-spring.shardingsphere.datasource.ds-1.driver-class-name=com.mysql.jdbc.Driver
-spring.shardingsphere.datasource.ds-1.username=root
-spring.shardingsphere.datasource.ds-1.password=
-
-spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-column=user_id
-spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-algorithm-name=database-inline
-spring.shardingsphere.rules.sharding.binding-tables[0]=t_order,t_order_item
-spring.shardingsphere.rules.sharding.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.database-inline.type=INLINE
-spring.shardingsphere.rules.sharding.sharding-algorithms.database-inline.props.algorithm-expression=ds-$->{user_id % 2}
-
-spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE
+spring.datasource.driver-class-name=org.apache.shardingsphere.driver.ShardingSphereDriver
+spring.datasource.url=jdbc:shardingsphere:classpath:sharding-databases.yaml
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-tables.properties b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-tables.properties
index 83eb6e33488..4b6a1fe81b0 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-tables.properties
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-tables.properties
@@ -15,36 +15,5 @@
# limitations under the License.
#
-spring.shardingsphere.mode.type=Standalone
-
-spring.shardingsphere.datasource.names=ds
-
-spring.shardingsphere.datasource.ds.type=com.zaxxer.hikari.HikariDataSource
-spring.shardingsphere.datasource.ds.driver-class-name=com.mysql.jdbc.Driver
-spring.shardingsphere.datasource.ds.jdbc-url=jdbc:mysql://localhost:3306/demo_ds?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
-spring.shardingsphere.datasource.ds.username=root
-spring.shardingsphere.datasource.ds.password=
-
-spring.shardingsphere.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-inline
-
-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-inline
-
-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-inline.type=INLINE
-spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-inline.props.algorithm-expression=t_order_$->{order_id % 2}
-spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-item-inline.type=INLINE
-spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-item-inline.props.algorithm-expression=t_order_item_$->{order_id % 2}
-
-spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE
+spring.datasource.driver-class-name=org.apache.shardingsphere.driver.ShardingSphereDriver
+spring.datasource.url=jdbc:shardingsphere:classpath:sharding-tables.yaml
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/application.properties b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/application.properties
index fb5c92934d1..9971c056055 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/application.properties
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/application.properties
@@ -17,7 +17,7 @@
mybatis.config-location=classpath:META-INF/mybatis-config.xml
-spring.profiles.active=sharding-databases
-#spring.profiles.active=sharding-tables
+#spring.profiles.active=sharding-databases
+spring.profiles.active=sharding-tables
#spring.profiles.active=sharding-databases-tables
#spring.profiles.active=sharding-auto-tables
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/sharding-auto-tables.yaml b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/sharding-auto-tables.yaml
new file mode 100644
index 00000000000..511cbe93369
--- /dev/null
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/sharding-auto-tables.yaml
@@ -0,0 +1,72 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+dataSources:
+ ds-0:
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ jdbcUrl: jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+ username: root
+ password:
+ ds-1:
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ jdbcUrl: jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+ username: root
+ password:
+
+rules:
+- !SHARDING
+ autoTables:
+ t_order:
+ actualDataSources: ds-0,ds-1
+ shardingStrategy:
+ standard:
+ shardingColumn: order_id
+ shardingAlgorithmName: auto-mod
+ keyGenerateStrategy:
+ column: order_id
+ keyGeneratorName: snowflake
+ t_order_item:
+ actualDataSources: ds-0,ds-1
+ shardingStrategy:
+ standard:
+ shardingColumn: order_item_id
+ shardingAlgorithmName: auto-mod
+ keyGenerateStrategy:
+ column: order_item_id
+ keyGeneratorName: snowflake
+ bindingTables:
+ - t_order,t_order_item
+ defaultDatabaseStrategy:
+ standard:
+ shardingColumn: user_id
+ shardingAlgorithmName: database-inline
+
+ shardingAlgorithms:
+ database-inline:
+ type: INLINE
+ props:
+ algorithm-expression: ds-$->{user_id % 2}
+ auto-mod:
+ type: MOD
+ props:
+ sharding-count: 4
+
+ keyGenerators:
+ snowflake:
+ type: SNOWFLAKE
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/sharding-databases-tables.yaml b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/sharding-databases-tables.yaml
new file mode 100644
index 00000000000..bd3c37447c4
--- /dev/null
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/sharding-databases-tables.yaml
@@ -0,0 +1,78 @@
+#
+# 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-inline
+ 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-inline
+ keyGenerateStrategy:
+ column: order_item_id
+ keyGeneratorName: snowflake
+ bindingTables:
+ - t_order,t_order_item
+ broadcastTables:
+ - t_address
+ defaultDatabaseStrategy:
+ standard:
+ shardingColumn: user_id
+ shardingAlgorithmName: database-inline
+
+ shardingAlgorithms:
+ database-inline:
+ type: INLINE
+ props:
+ algorithm-expression: ds-$->{user_id % 2}
+ t-order-inline:
+ type: INLINE
+ props:
+ algorithm-expression: t_order_$->{order_id % 2}
+ t-order-item-inline:
+ type: INLINE
+ props:
+ algorithm-expression: t_order_item_$->{order_id % 2}
+
+ keyGenerators:
+ snowflake:
+ type: SNOWFLAKE
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/sharding-databases.yaml b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/sharding-databases.yaml
new file mode 100644
index 00000000000..65d86dbdea7
--- /dev/null
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/sharding-databases.yaml
@@ -0,0 +1,62 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+dataSources:
+ ds-0:
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ jdbcUrl: jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+ username: root
+ password:
+ ds-1:
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ jdbcUrl: jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+ username: root
+ password:
+
+rules:
+- !SHARDING
+ tables:
+ t_order:
+ actualDataNodes: ds-${0..1}.t_order
+ keyGenerateStrategy:
+ column: order_id
+ keyGeneratorName: snowflake
+ t_order_item:
+ actualDataNodes: ds-${0..1}.t_order_item
+ keyGenerateStrategy:
+ column: order_item_id
+ keyGeneratorName: snowflake
+ bindingTables:
+ - t_order,t_order_item
+ broadcastTables:
+ - t_address
+ defaultDatabaseStrategy:
+ standard:
+ shardingColumn: user_id
+ shardingAlgorithmName: database-inline
+
+ shardingAlgorithms:
+ database-inline:
+ type: INLINE
+ props:
+ algorithm-expression: ds-$->{user_id % 2}
+
+ keyGenerators:
+ snowflake:
+ type: SNOWFLAKE
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/sharding-tables.yaml b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/sharding-tables.yaml
new file mode 100644
index 00000000000..a792936961f
--- /dev/null
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/sharding-tables.yaml
@@ -0,0 +1,64 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+dataSources:
+ ds:
+ dataSourceClassName: com.zaxxer.hikari.HikariDataSource
+ driverClassName: com.mysql.jdbc.Driver
+ jdbcUrl: jdbc:mysql://localhost:3306/demo_ds?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+ username: root
+ password:
+
+rules:
+- !SHARDING
+ tables:
+ t_order:
+ actualDataNodes: ds.t_order_$->{0..1}
+ tableStrategy:
+ standard:
+ shardingColumn: order_id
+ shardingAlgorithmName: t-order-inline
+ keyGenerateStrategy:
+ column: order_id
+ keyGeneratorName: snowflake
+ t_order_item:
+ actualDataNodes: ds.t_order_item_$->{0..1}
+ tableStrategy:
+ standard:
+ shardingColumn: order_id
+ shardingAlgorithmName: t-order-item-inline
+ keyGenerateStrategy:
+ column: order_item_id
+ keyGeneratorName: snowflake
+ bindingTables:
+ - t_order,t_order_item
+ broadcastTables:
+ - t_address
+
+ shardingAlgorithms:
+ t-order-inline:
+ type: INLINE
+ props:
+ algorithm-expression: t_order_$->{order_id % 2}
+ t-order-item-inline:
+ type: INLINE
+ props:
+ algorithm-expression: t_order_item_$->{order_id % 2}
+
+ keyGenerators:
+ snowflake:
+ type: SNOWFLAKE
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-jpa-example/pom.xml b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-jpa-example/pom.xml
index de18fddd33e..e32b8b13df9 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-jpa-example/pom.xml
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-jpa-example/pom.xml
@@ -37,7 +37,7 @@
<dependency>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-jdbc-core-spring-namespace</artifactId>
+ <artifactId>shardingsphere-jdbc-core</artifactId>
</dependency>
</dependencies>
</project>
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-jpa-example/src/main/resources/META-INF/application-sharding-databases-tables.xml b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-jpa-example/src/main/resources/META-INF/application-sharding-databases-tables.xml
index e19774a6a88..d939f6117cd 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-jpa-example/src/main/resources/META-INF/application-sharding-databases-tables.xml
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-jpa-example/src/main/resources/META-INF/application-sharding-databases-tables.xml
@@ -21,18 +21,12 @@
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
- xmlns:shardingsphere="http://shardingsphere.apache.org/schema/shardingsphere/datasource"
- xmlns:sharding="http://shardingsphere.apache.org/schema/shardingsphere/sharding"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
- http://shardingsphere.apache.org/schema/shardingsphere/datasource
- http://shardingsphere.apache.org/schema/shardingsphere/datasource/datasource.xsd
- http://shardingsphere.apache.org/schema/shardingsphere/sharding
- http://shardingsphere.apache.org/schema/shardingsphere/sharding/sharding.xsd
">
<context:annotation-config />
<context:component-scan base-package="org.apache.shardingsphere.example.core.jpa" />
@@ -54,76 +48,8 @@
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager" p:entityManagerFactory-ref="entityManagerFactory" />
<tx:annotation-driven />
- <bean id="demo_ds_0" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
- <property name="driverClassName" value="com.mysql.jdbc.Driver" />
- <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8" />
- <property name="username" value="root" />
- <property name="password" value="" />
- <property name="maximumPoolSize" value="16" />
+ <bean 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="" />
- <property name="maximumPoolSize" value="16" />
- </bean>
-
- <sharding:sharding-algorithm id="databaseAlgorithm" type="INLINE">
- <props>
- <prop key="algorithm-expression">demo_ds_${user_id % 2}</prop>
- </props>
- </sharding:sharding-algorithm>
- <sharding:standard-strategy id="databaseStrategy" sharding-column="user_id" algorithm-ref="databaseAlgorithm" />
-
- <sharding:sharding-algorithm id="orderTableAlgorithm" type="INLINE">
- <props>
- <prop key="algorithm-expression">t_order_${order_id % 2}</prop>
- </props>
- </sharding:sharding-algorithm>
-
- <sharding:sharding-algorithm id="accountTableAlgorithm" type="INLINE">
- <props>
- <prop key="algorithm-expression">t_account_${account_id % 2}</prop>
- </props>
- </sharding:sharding-algorithm>
-
- <sharding:standard-strategy id="orderTableStrategy" sharding-column="order_id" algorithm-ref="orderTableAlgorithm" />
-
- <sharding:standard-strategy id="accountTableStrategy" algorithm-ref="accountTableAlgorithm" />
-
- <sharding:sharding-algorithm id="orderItemTableAlgorithm" type="INLINE">
- <props>
- <prop key="algorithm-expression">t_order_item_${order_id % 2}</prop>
- </props>
- </sharding:sharding-algorithm>
- <sharding:standard-strategy id="orderItemTableStrategy" sharding-column="order_id" algorithm-ref="orderItemTableAlgorithm" />
-
- <sharding:key-generate-algorithm id="snowflakeAlgorithm" type="SNOWFLAKE">
- </sharding:key-generate-algorithm>
-
- <sharding:key-generate-strategy id="orderKeyGenerator" column="order_id" algorithm-ref="snowflakeAlgorithm" />
- <sharding:key-generate-strategy id="itemKeyGenerator" column="order_item_id" algorithm-ref="snowflakeAlgorithm" />
- <sharding:key-generate-strategy id="accountKeyGenerator" column="account_id" algorithm-ref="snowflakeAlgorithm" />
-
- <sharding:rule id="shardingRule" default-sharding-column="account_id">
- <sharding:table-rules>
- <sharding:table-rule logic-table="t_order" actual-data-nodes="demo_ds_${0..1}.t_order_${0..1}" database-strategy-ref="databaseStrategy" table-strategy-ref="orderTableStrategy" key-generate-strategy-ref="orderKeyGenerator" />
- <sharding:table-rule logic-table="t_order_item" actual-data-nodes="demo_ds_${0..1}.t_order_item_${0..1}" database-strategy-ref="databaseStrategy" table-strategy-ref="orderItemTableStrategy" key-generate-strategy-ref="itemKeyGenerator" />
- <sharding:table-rule logic-table="t_account" actual-data-nodes="demo_ds_${0..1}.t_account_${0..1}" database-strategy-ref="databaseStrategy" table-strategy-ref="accountTableStrategy" key-generate-strategy-ref="accountKeyGenerator" />
- </sharding:table-rules>
- <sharding:binding-table-rules>
- <sharding:binding-table-rule logic-tables="t_order,t_order_item" />
- </sharding:binding-table-rules>
- <sharding:broadcast-table-rules>
- <sharding:broadcast-table-rule table="t_address" />
- </sharding:broadcast-table-rules>
- </sharding:rule>
-
- <shardingsphere:data-source id="shardingDataSource" data-source-names="demo_ds_0, demo_ds_1" rule-refs="shardingRule">
- <props>
- <prop key="sql-show">false</prop>
- </props>
- </shardingsphere:data-source>
</beans>
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-jpa-example/src/main/resources/META-INF/application-sharding-databases.xml b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-jpa-example/src/main/resources/META-INF/application-sharding-databases.xml
index 1f59cab681f..e3f63b9167d 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-jpa-example/src/main/resources/META-INF/application-sharding-databases.xml
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-jpa-example/src/main/resources/META-INF/application-sharding-databases.xml
@@ -21,22 +21,16 @@
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
- xmlns:shardingsphere="http://shardingsphere.apache.org/schema/shardingsphere/datasource"
- xmlns:sharding="http://shardingsphere.apache.org/schema/shardingsphere/sharding"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
- http://shardingsphere.apache.org/schema/shardingsphere/datasource
- http://shardingsphere.apache.org/schema/shardingsphere/datasource/datasource.xsd
- http://shardingsphere.apache.org/schema/shardingsphere/sharding
- http://shardingsphere.apache.org/schema/shardingsphere/sharding/sharding.xsd
">
<context:annotation-config />
<context:component-scan base-package="org.apache.shardingsphere.example.core.jpa" />
-
+
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="shardingDataSource" />
<property name="jpaVendorAdapter">
@@ -54,47 +48,8 @@
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager" p:entityManagerFactory-ref="entityManagerFactory" />
<tx:annotation-driven />
- <bean id="demo_ds_0" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
- <property name="driverClassName" value="com.mysql.jdbc.Driver" />
- <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8" />
- <property name="username" value="root" />
- <property name="password" value="" />
+ <bean 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:sharding-algorithm id="databaseAlgorithm" type="INLINE">
- <props>
- <prop key="algorithm-expression">demo_ds_${user_id % 2}</prop>
- </props>
- </sharding:sharding-algorithm>
- <sharding:standard-strategy id="databaseStrategy" sharding-column="user_id" algorithm-ref="databaseAlgorithm" />
-
- <sharding:key-generate-algorithm id="snowflakeAlgorithm" type="SNOWFLAKE">
- </sharding:key-generate-algorithm>
-
- <sharding:key-generate-strategy id="orderKeyGenerator" column="order_id" algorithm-ref="snowflakeAlgorithm" />
- <sharding:key-generate-strategy id="accountKeyGenerator" column="account_id" algorithm-ref="snowflakeAlgorithm" />
- <sharding:key-generate-strategy id="itemKeyGenerator" column="order_item_id" algorithm-ref="snowflakeAlgorithm" />
-
- <sharding:rule id="shardingRule">
- <sharding:table-rules>
- <sharding:table-rule logic-table="t_order" database-strategy-ref="databaseStrategy" key-generate-strategy-ref="orderKeyGenerator" />
- <sharding:table-rule logic-table="t_order_item" database-strategy-ref="databaseStrategy" key-generate-strategy-ref="itemKeyGenerator" />
- <sharding:table-rule logic-table="t_account" database-strategy-ref="databaseStrategy" key-generate-strategy-ref="accountKeyGenerator" />
- </sharding:table-rules>
- <sharding:binding-table-rules>
- <sharding:binding-table-rule logic-tables="t_order,t_order_item" />
- </sharding:binding-table-rules>
- <sharding:broadcast-table-rules>
- <sharding:broadcast-table-rule table="t_address" />
- </sharding:broadcast-table-rules>
- </sharding:rule>
-
- <shardingsphere:data-source id="shardingDataSource" data-source-names="demo_ds_0, demo_ds_1" rule-refs="shardingRule" />
</beans>
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-jpa-example/src/main/resources/META-INF/application-sharding-tables.xml b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-jpa-example/src/main/resources/META-INF/application-sharding-tables.xml
index 8a9325bca26..001bddb3ac6 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-jpa-example/src/main/resources/META-INF/application-sharding-tables.xml
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-jpa-example/src/main/resources/META-INF/application-sharding-tables.xml
@@ -21,18 +21,12 @@
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
- xmlns:shardingsphere="http://shardingsphere.apache.org/schema/shardingsphere/datasource"
- xmlns:sharding="http://shardingsphere.apache.org/schema/shardingsphere/sharding"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
- http://shardingsphere.apache.org/schema/shardingsphere/datasource
- http://shardingsphere.apache.org/schema/shardingsphere/datasource/datasource.xsd
- http://shardingsphere.apache.org/schema/shardingsphere/sharding
- http://shardingsphere.apache.org/schema/shardingsphere/sharding/sharding.xsd
">
<context:annotation-config />
<context:component-scan base-package="org.apache.shardingsphere.example.core.jpa" />
@@ -54,56 +48,8 @@
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager" p:entityManagerFactory-ref="entityManagerFactory" />
<tx:annotation-driven />
- <bean id="demo_ds" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
- <property name="driverClassName" value="com.mysql.jdbc.Driver" />
- <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/demo_ds?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8" />
- <property name="username" value="root" />
- <property name="password" value="" />
+ <bean 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:sharding-algorithm id="orderTableAlgorithm" type="INLINE">
- <props>
- <prop key="algorithm-expression">t_order_${order_id % 2}</prop>
- </props>
- </sharding:sharding-algorithm>
-
- <sharding:sharding-algorithm id="accountTableAlgorithm" type="INLINE">
- <props>
- <prop key="algorithm-expression">t_account_${account_id % 2}</prop>
- </props>
- </sharding:sharding-algorithm>
-
- <sharding:standard-strategy id="orderTableStrategy" sharding-column="order_id" algorithm-ref="orderTableAlgorithm" />
-
- <sharding:standard-strategy id="accountTableStrategy" algorithm-ref="accountTableAlgorithm" />
-
- <sharding:sharding-algorithm id="orderItemTableAlgorithm" type="INLINE">
- <props>
- <prop key="algorithm-expression">t_order_item_${order_id % 2}</prop>
- </props>
- </sharding:sharding-algorithm>
- <sharding:standard-strategy id="orderItemTableStrategy" sharding-column="order_id" algorithm-ref="orderItemTableAlgorithm" />
-
- <sharding:key-generate-algorithm id="snowflakeAlgorithm" type="SNOWFLAKE">
- </sharding:key-generate-algorithm>
-
- <sharding:key-generate-strategy id="orderKeyGenerator" column="order_id" algorithm-ref="snowflakeAlgorithm" />
- <sharding:key-generate-strategy id="itemKeyGenerator" column="order_item_id" algorithm-ref="snowflakeAlgorithm" />
- <sharding:key-generate-strategy id="accountKeyGenerator" column="account_id" algorithm-ref="snowflakeAlgorithm" />
-
- <sharding:rule id="shardingRule" default-sharding-column="account_id">
- <sharding:table-rules>
- <sharding:table-rule logic-table="t_order" actual-data-nodes="demo_ds.t_order_${0..1}" table-strategy-ref="orderTableStrategy" key-generate-strategy-ref="orderKeyGenerator" />
- <sharding:table-rule logic-table="t_order_item" actual-data-nodes="demo_ds.t_order_item_${0..1}" table-strategy-ref="orderItemTableStrategy" key-generate-strategy-ref="itemKeyGenerator" />
- <sharding:table-rule logic-table="t_account" actual-data-nodes="demo_ds.t_account_${0..1}" table-strategy-ref="accountTableStrategy" key-generate-strategy-ref="accountKeyGenerator" />
- </sharding:table-rules>
- <sharding:binding-table-rules>
- <sharding:binding-table-rule logic-tables="t_order,t_order_item" />
- </sharding:binding-table-rules>
- <sharding:broadcast-table-rules>
- <sharding:broadcast-table-rule table="t_address" />
- </sharding:broadcast-table-rules>
- </sharding:rule>
-
- <shardingsphere:data-source id="shardingDataSource" data-source-names="demo_ds" rule-refs="shardingRule" />
</beans>
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-jpa-example/src/main/resources/sharding-databases-tables.yaml b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-jpa-example/src/main/resources/sharding-databases-tables.yaml
new file mode 100644
index 00000000000..bbf980ff311
--- /dev/null
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-jpa-example/src/main/resources/sharding-databases-tables.yaml
@@ -0,0 +1,96 @@
+#
+# 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:
+ demo_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:
+ maximumPoolSize: 16
+ demo_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:
+ maximumPoolSize: 16
+
+rules:
+- !SHARDING
+ tables:
+ t_order:
+ actualDataNodes: demo_ds_$->{0..1}.t_order_$->{0..1}
+ tableStrategy:
+ standard:
+ shardingColumn: order_id
+ shardingAlgorithmName: t-order-inline
+ keyGenerateStrategy:
+ column: order_id
+ keyGeneratorName: snowflake
+ t_order_item:
+ actualDataNodes: demo_ds_$->{0..1}.t_order_item_$->{0..1}
+ tableStrategy:
+ standard:
+ shardingColumn: order_id
+ shardingAlgorithmName: t-order-item-inline
+ keyGenerateStrategy:
+ column: order_item_id
+ keyGeneratorName: snowflake
+ t_account:
+ actualDataNodes: demo_ds_$->{0..1}.t_account_$->{0..1}
+ tableStrategy:
+ standard:
+ shardingAlgorithmName: t-account-inline
+ keyGenerateStrategy:
+ column: account_id
+ keyGeneratorName: snowflake
+ bindingTables:
+ - t_order,t_order_item
+ broadcastTables:
+ - t_address
+ defaultShardingColumn: account_id
+ defaultDatabaseStrategy:
+ standard:
+ shardingColumn: user_id
+ shardingAlgorithmName: database-inline
+
+ shardingAlgorithms:
+ database-inline:
+ type: INLINE
+ props:
+ algorithm-expression: demo_ds_$->{user_id % 2}
+ t-order-inline:
+ type: INLINE
+ props:
+ algorithm-expression: t_order_$->{order_id % 2}
+ t-order-item-inline:
+ type: INLINE
+ props:
+ algorithm-expression: t_order_item_$->{order_id % 2}
+ t-account-inline:
+ type: INLINE
+ props:
+ algorithm-expression: t_account_$->{account_id % 2}
+
+ keyGenerators:
+ snowflake:
+ type: SNOWFLAKE
+
+props:
+ sql-show: false
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-jpa-example/src/main/resources/sharding-databases.yaml b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-jpa-example/src/main/resources/sharding-databases.yaml
new file mode 100644
index 00000000000..04bb062c954
--- /dev/null
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/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:
+ demo_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:
+ demo_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: demo_ds_${0..1}.t_order
+ keyGenerateStrategy:
+ column: order_id
+ keyGeneratorName: snowflake
+ t_order_item:
+ actualDataNodes: demo_ds_${0..1}.t_order_item
+ keyGenerateStrategy:
+ column: order_item_id
+ keyGeneratorName: snowflake
+ t_account:
+ actualDataNodes: demo_ds_${0..1}.t_account
+ keyGenerateStrategy:
+ column: account_id
+ keyGeneratorName: snowflake
+ bindingTables:
+ - t_order,t_order_item
+ broadcastTables:
+ - t_address
+ defaultDatabaseStrategy:
+ standard:
+ shardingColumn: user_id
+ shardingAlgorithmName: database-inline
+
+ shardingAlgorithms:
+ database-inline:
+ type: INLINE
+ props:
+ algorithm-expression: demo_ds_${user_id % 2}
+
+ keyGenerators:
+ snowflake:
+ type: SNOWFLAKE
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-jpa-example/src/main/resources/sharding-tables.yaml b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-jpa-example/src/main/resources/sharding-tables.yaml
new file mode 100644
index 00000000000..ae752b994eb
--- /dev/null
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-jpa-example/src/main/resources/sharding-tables.yaml
@@ -0,0 +1,77 @@
+#
+# 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:
+ demo_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: demo_ds.t_order_$->{0..1}
+ tableStrategy:
+ standard:
+ shardingColumn: order_id
+ shardingAlgorithmName: t-order-inline
+ keyGenerateStrategy:
+ column: order_id
+ keyGeneratorName: snowflake
+ t_order_item:
+ actualDataNodes: demo_ds.t_order_item_$->{0..1}
+ tableStrategy:
+ standard:
+ shardingColumn: order_id
+ shardingAlgorithmName: t-order-item-inline
+ keyGenerateStrategy:
+ column: order_item_id
+ keyGeneratorName: snowflake
+ t_account:
+ actualDataNodes: demo_ds.t_account_$->{0..1}
+ tableStrategy:
+ standard:
+ shardingAlgorithmName: t-account-inline
+ keyGenerateStrategy:
+ column: account_id
+ keyGeneratorName: snowflake
+ bindingTables:
+ - t_order,t_order_item
+ broadcastTables:
+ - t_address
+ defaultShardingColumn: account_id
+
+ shardingAlgorithms:
+ t-order-inline:
+ type: INLINE
+ props:
+ algorithm-expression: t_order_$->{order_id % 2}
+ t-order-item-inline:
+ type: INLINE
+ props:
+ algorithm-expression: t_order_item_$->{order_id % 2}
+ t-account-inline:
+ type: INLINE
+ props:
+ algorithm-expression: t_account_$->{order_id % 2}
+
+ keyGenerators:
+ snowflake:
+ type: SNOWFLAKE
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-mybatis-example/pom.xml b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-mybatis-example/pom.xml
index 8d472e89bad..2cce00ba8e0 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-mybatis-example/pom.xml
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-mybatis-example/pom.xml
@@ -37,7 +37,7 @@
<dependency>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-jdbc-core-spring-namespace</artifactId>
+ <artifactId>shardingsphere-jdbc-core</artifactId>
</dependency>
</dependencies>
</project>
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-mybatis-example/src/main/resources/META-INF/application-sharding-databases-tables.xml b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-mybatis-example/src/main/resources/META-INF/application-sharding-databases-tables.xml
index faa4c90ca7f..607ab200f74 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-mybatis-example/src/main/resources/META-INF/application-sharding-databases-tables.xml
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-mybatis-example/src/main/resources/META-INF/application-sharding-databases-tables.xml
@@ -20,80 +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="inlineDatabaseStrategyAlgorithm" />
- <sharding:standard-strategy id="orderTableStrategy" sharding-column="order_id" algorithm-ref="inlineOrderTableStrategyAlgorithm" />
- <sharding:standard-strategy id="orderItemTableStrategy" sharding-column="order_id" algorithm-ref="inlineOrderItemTableStrategyAlgorithm" />
-
- <sharding:sharding-algorithm id="inlineDatabaseStrategyAlgorithm" type="INLINE">
- <props>
- <prop key="algorithm-expression">demo_ds_${user_id % 2}</prop>
- </props>
- </sharding:sharding-algorithm>
- <sharding:sharding-algorithm id="inlineOrderTableStrategyAlgorithm" type="INLINE">
- <props>
- <prop key="algorithm-expression">t_order_${order_id % 2}</prop>
- </props>
- </sharding:sharding-algorithm>
- <sharding:sharding-algorithm id="inlineOrderItemTableStrategyAlgorithm" type="INLINE">
- <props>
- <prop key="algorithm-expression">t_order_item_${order_id % 2}</prop>
- </props>
- </sharding:sharding-algorithm>
-
- <sharding:key-generate-algorithm id="snowflakeAlgorithm" type="SNOWFLAKE">
- </sharding:key-generate-algorithm>
-
- <sharding:key-generate-strategy id="orderKeyGenerator" column="order_id" algorithm-ref="snowflakeAlgorithm" />
- <sharding:key-generate-strategy id="itemKeyGenerator" column="order_item_id" algorithm-ref="snowflakeAlgorithm" />
-
- <sharding:rule id="shardingRule">
- <sharding:table-rules>
- <sharding:table-rule logic-table="t_order" actual-data-nodes="demo_ds_${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/sharding-example/sharding-spring-namespace-mybatis-example/src/main/resources/META-INF/application-sharding-databases.xml b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-mybatis-example/src/main/resources/META-INF/application-sharding-databases.xml
index 3abdeec9181..dcde9b5c6c0 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-mybatis-example/src/main/resources/META-INF/application-sharding-databases.xml
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-mybatis-example/src/main/resources/META-INF/application-sharding-databases.xml
@@ -20,64 +20,20 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
- xmlns:shardingsphere="http://shardingsphere.apache.org/schema/shardingsphere/datasource"
- xmlns:sharding="http://shardingsphere.apache.org/schema/shardingsphere/sharding"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
- http://shardingsphere.apache.org/schema/shardingsphere/datasource
- http://shardingsphere.apache.org/schema/shardingsphere/datasource/datasource.xsd
- http://shardingsphere.apache.org/schema/shardingsphere/sharding
- http://shardingsphere.apache.org/schema/shardingsphere/sharding/sharding.xsd
">
<context:component-scan base-package="org.apache.shardingsphere.example.core.mybatis" />
- <bean id="demo_ds_0" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
- <property name="driverClassName" value="com.mysql.jdbc.Driver" />
- <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8" />
- <property name="username" value="root" />
- <property name="password" value="" />
+ <bean 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="inlineStrategyShardingAlgorithm" />
-
- <sharding:sharding-algorithm id="inlineStrategyShardingAlgorithm" type="INLINE">
- <props>
- <prop key="algorithm-expression">demo_ds_${user_id % 2}</prop>
- </props>
- </sharding:sharding-algorithm>
-
- <sharding:key-generate-algorithm id="snowflakeAlgorithm" type="SNOWFLAKE">
- </sharding:key-generate-algorithm>
-
- <sharding:key-generate-strategy id="orderKeyGenerator" column="order_id" algorithm-ref="snowflakeAlgorithm" />
- <sharding:key-generate-strategy id="itemKeyGenerator" column="order_item_id" algorithm-ref="snowflakeAlgorithm" />
-
- <sharding:rule id="shardingRule">
- <sharding:table-rules>
- <sharding:table-rule logic-table="t_order" database-strategy-ref="databaseStrategy" key-generate-strategy-ref="orderKeyGenerator" />
- <sharding:table-rule logic-table="t_order_item" database-strategy-ref="databaseStrategy" key-generate-strategy-ref="itemKeyGenerator" />
- </sharding:table-rules>
- <sharding:binding-table-rules>
- <sharding:binding-table-rule logic-tables="t_order,t_order_item" />
- </sharding:binding-table-rules>
- <sharding:broadcast-table-rules>
- <sharding:broadcast-table-rule table="t_address" />
- </sharding:broadcast-table-rules>
- </sharding:rule>
-
- <shardingsphere:data-source id="shardingDataSource" database-name="sharding-databases" data-source-names="demo_ds_0, demo_ds_1" rule-refs="shardingRule" />
-
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="shardingDataSource" />
</bean>
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-mybatis-example/src/main/resources/META-INF/application-sharding-tables.xml b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-mybatis-example/src/main/resources/META-INF/application-sharding-tables.xml
index b8bb9c0e506..43b87c3e272 100644
--- a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-mybatis-example/src/main/resources/META-INF/application-sharding-tables.xml
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-mybatis-example/src/main/resources/META-INF/application-sharding-tables.xml
@@ -20,67 +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="inlineOrderTableStrategyAlgorithm" />
- <sharding:standard-strategy id="orderItemTableStrategy" sharding-column="order_id" algorithm-ref="inlineOrderItemTableStrategyAlgorithm" />
-
- <sharding:sharding-algorithm id="inlineOrderTableStrategyAlgorithm" type="INLINE">
- <props>
- <prop key="algorithm-expression">t_order_${order_id % 2}</prop>
- </props>
- </sharding:sharding-algorithm>
- <sharding:sharding-algorithm id="inlineOrderItemTableStrategyAlgorithm" type="INLINE">
- <props>
- <prop key="algorithm-expression">t_order_item_${order_id % 2}</prop>
- </props>
- </sharding:sharding-algorithm>
-
- <sharding:key-generate-algorithm id="snowflakeAlgorithm" type="SNOWFLAKE">
- </sharding:key-generate-algorithm>
-
- <sharding:key-generate-strategy id="orderKeyGenerator" column="order_id" algorithm-ref="snowflakeAlgorithm" />
- <sharding:key-generate-strategy id="itemKeyGenerator" column="order_item_id" algorithm-ref="snowflakeAlgorithm" />
-
- <sharding:rule id="shardingRule">
- <sharding:table-rules>
- <sharding:table-rule logic-table="t_order" actual-data-nodes="demo_ds.t_order_${0..1}" table-strategy-ref="orderTableStrategy" key-generate-strategy-ref="orderKeyGenerator" />
- <sharding:table-rule logic-table="t_order_item" actual-data-nodes="demo_ds.t_order_item_${0..1}" table-strategy-ref="orderItemTableStrategy" key-generate-strategy-ref="itemKeyGenerator" />
- </sharding:table-rules>
- <sharding:binding-table-rules>
- <sharding:binding-table-rule logic-tables="t_order,t_order_item" />
- </sharding:binding-table-rules>
- <sharding:broadcast-table-rules>
- <sharding:broadcast-table-rule table="t_address" />
- </sharding:broadcast-table-rules>
- </sharding:rule>
-
- <shardingsphere:data-source id="shardingDataSource" data-source-names="demo_ds" rule-refs="shardingRule">
- <props>
- <prop key="sql-show">false</prop>
- </props>
- </shardingsphere:data-source>
-
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="shardingDataSource" />
</bean>
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-mybatis-example/src/main/resources/sharding-databases-tables.yaml b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-mybatis-example/src/main/resources/sharding-databases-tables.yaml
new file mode 100644
index 00000000000..6ecb9e62744
--- /dev/null
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-mybatis-example/src/main/resources/sharding-databases-tables.yaml
@@ -0,0 +1,81 @@
+#
+# 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:
+ demo_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:
+ demo_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: demo_ds_$->{0..1}.t_order_$->{0..1}
+ tableStrategy:
+ standard:
+ shardingColumn: order_id
+ shardingAlgorithmName: t-order-inline
+ keyGenerateStrategy:
+ column: order_id
+ keyGeneratorName: snowflake
+ t_order_item:
+ actualDataNodes: demo_ds_$->{0..1}.t_order_item_$->{0..1}
+ tableStrategy:
+ standard:
+ shardingColumn: order_id
+ shardingAlgorithmName: t-order-item-inline
+ keyGenerateStrategy:
+ column: order_item_id
+ keyGeneratorName: snowflake
+ bindingTables:
+ - t_order,t_order_item
+ broadcastTables:
+ - t_address
+ defaultDatabaseStrategy:
+ standard:
+ shardingColumn: user_id
+ shardingAlgorithmName: database-inline
+
+ shardingAlgorithms:
+ database-inline:
+ type: INLINE
+ props:
+ algorithm-expression: demo_ds_$->{user_id % 2}
+ t-order-inline:
+ type: INLINE
+ props:
+ algorithm-expression: t_order_$->{order_id % 2}
+ t-order-item-inline:
+ type: INLINE
+ props:
+ algorithm-expression: t_order_item_$->{order_id % 2}
+
+ keyGenerators:
+ snowflake:
+ type: SNOWFLAKE
+
+props:
+ sql-show: false
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-mybatis-example/src/main/resources/sharding-databases.yaml b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-mybatis-example/src/main/resources/sharding-databases.yaml
new file mode 100644
index 00000000000..d8337e21148
--- /dev/null
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-mybatis-example/src/main/resources/sharding-databases.yaml
@@ -0,0 +1,62 @@
+#
+# 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:
+ demo_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:
+ demo_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: demo_ds_${0..1}.t_order
+ keyGenerateStrategy:
+ column: order_id
+ keyGeneratorName: snowflake
+ t_order_item:
+ actualDataNodes: demo_ds_${0..1}.t_order_item
+ keyGenerateStrategy:
+ column: order_item_id
+ keyGeneratorName: snowflake
+ bindingTables:
+ - t_order,t_order_item
+ broadcastTables:
+ - t_address
+ defaultDatabaseStrategy:
+ standard:
+ shardingColumn: user_id
+ shardingAlgorithmName: database-inline
+
+ shardingAlgorithms:
+ database-inline:
+ type: INLINE
+ props:
+ algorithm-expression: demo_ds_${user_id % 2}
+
+ keyGenerators:
+ snowflake:
+ type: SNOWFLAKE
diff --git a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-mybatis-example/src/main/resources/sharding-tables.yaml b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-mybatis-example/src/main/resources/sharding-tables.yaml
new file mode 100644
index 00000000000..6ec04c17b86
--- /dev/null
+++ b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-namespace-mybatis-example/src/main/resources/sharding-tables.yaml
@@ -0,0 +1,67 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+dataSources:
+ demo_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: demo_ds.t_order_$->{0..1}
+ tableStrategy:
+ standard:
+ shardingColumn: order_id
+ shardingAlgorithmName: t-order-inline
+ keyGenerateStrategy:
+ column: order_id
+ keyGeneratorName: snowflake
+ t_order_item:
+ actualDataNodes: demo_ds.t_order_item_$->{0..1}
+ tableStrategy:
+ standard:
+ shardingColumn: order_id
+ shardingAlgorithmName: t-order-item-inline
+ keyGenerateStrategy:
+ column: order_item_id
+ keyGeneratorName: snowflake
+ bindingTables:
+ - t_order,t_order_item
+ broadcastTables:
+ - t_address
+
+ shardingAlgorithms:
+ t-order-inline:
+ type: INLINE
+ props:
+ algorithm-expression: t_order_$->{order_id % 2}
+ t-order-item-inline:
+ type: INLINE
+ props:
+ algorithm-expression: t_order_item_$->{order_id % 2}
+
+ keyGenerators:
+ snowflake:
+ type: SNOWFLAKE
+
+props:
+ spl-show: false