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 8bbb048  Add spi-based-sharding-spring-boot-mybatis-example for 
spi-based-shar… (#15786)
8bbb048 is described below

commit 8bbb0484f1ee379ceddcf9dc9d7959c7be1db826
Author: 亥时 <[email protected]>
AuthorDate: Mon Mar 7 11:38:46 2022 +0800

    Add spi-based-sharding-spring-boot-mybatis-example for spi-based-shar… 
(#15786)
    
    * Add spi-based-sharding-spring-boot-mybatis-example for 
spi-based-sharding-algorithm-example #15719
    
    * add head license
    
    * remove personal author info & format pom
    
    * add final for paremeters&slim empty fun
    
    * add a blank line eof
---
 .../spi-based-sharding-algorithm-example/pom.xml   |  1 +
 .../pom.xml                                        | 33 +++++++++---
 .../SPIBasedShardingSpringBootMybatisExample.java  | 40 +++++++++++++++
 ...DatasourceStandardShardingAlgorithmFixture.java | 54 ++++++++++++++++++++
 ...dOrderItemStandardShardingAlgorithmFixture.java | 55 ++++++++++++++++++++
 ...BasedOrderStandardShardingAlgorithmFixture.java | 54 ++++++++++++++++++++
 .../main/resources/META-INF/mybatis-config.xml}    | 29 ++++-------
 ...e.shardingsphere.sharding.spi.ShardingAlgorithm | 20 ++++++++
 .../application-sharding-auto-tables.properties    | 55 ++++++++++++++++++++
 ...pplication-sharding-databases-tables.properties | 59 ++++++++++++++++++++++
 .../application-sharding-databases.properties      | 49 ++++++++++++++++++
 .../application-sharding-tables.properties         | 48 ++++++++++++++++++
 .../src/main/resources/application.properties      | 23 +++++++++
 .../src/main/resources/logback.xml}                | 31 ++++++------
 14 files changed, 510 insertions(+), 41 deletions(-)

diff --git 
a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/pom.xml
 
b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/pom.xml
index bc2b0a9..13d5fc6 100644
--- 
a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/pom.xml
+++ 
b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/pom.xml
@@ -31,5 +31,6 @@
     
     <modules>
         <module>spi-based-sharding-raw-jdbc-example</module>
+        <module>spi-based-sharding-spring-boot-mybatis-example</module>
     </modules>
 </project>
diff --git 
a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/pom.xml
 
b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/pom.xml
similarity index 58%
copy from 
examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/pom.xml
copy to 
examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/pom.xml
index bc2b0a9..9e91616 100644
--- 
a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/pom.xml
+++ 
b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/pom.xml
@@ -21,15 +21,34 @@
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
     <modelVersion>4.0.0</modelVersion>
     <parent>
+        <artifactId>spi-based-sharding-algorithm-example</artifactId>
         <groupId>org.apache.shardingsphere.example</groupId>
-        <artifactId>custom-sharding-algortihm-example</artifactId>
         <version>${revision}</version>
     </parent>
-    <artifactId>spi-based-sharding-algorithm-example</artifactId>
+    <artifactId>spi-based-sharding-spring-boot-mybatis-example</artifactId>
     <name>${project.artifactId}</name>
-    <packaging>pom</packaging>
-    
-    <modules>
-        <module>spi-based-sharding-raw-jdbc-example</module>
-    </modules>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.shardingsphere.example</groupId>
+            <artifactId>example-spring-mybatis</artifactId>
+            <version>${project.parent.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.shardingsphere</groupId>
+            
<artifactId>shardingsphere-jdbc-core-spring-boot-starter</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.mybatis.spring.boot</groupId>
+            <artifactId>mybatis-spring-boot-starter</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+        </dependency>
+    </dependencies>
+
 </project>
diff --git 
a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/java/org/apache/shardingsphere/example/extension/spibased/sharding/spring/boot/mybatis/SPIBasedShardingSpringBootMybatisExample.java
 
b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm
 [...]
new file mode 100644
index 0000000..02bb952
--- /dev/null
+++ 
b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/java/org/apache/shardingsphere/example/extension/spibased/sharding/spring/boot/mybatis/SPIBasedShardingSpringBootMybatisExample.java
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ */
+
+package 
org.apache.shardingsphere.example.extension.spibased.sharding.spring.boot.mybatis;
+
+import org.apache.shardingsphere.example.core.api.ExampleExecuteTemplate;
+import org.apache.shardingsphere.example.core.api.service.ExampleService;
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.context.annotation.ComponentScan;
+
+import java.sql.SQLException;
+
+@ComponentScan("org.apache.shardingsphere.example.core.mybatis")
+@MapperScan(basePackages = 
"org.apache.shardingsphere.example.core.mybatis.repository")
+@SpringBootApplication
+public class SPIBasedShardingSpringBootMybatisExample {
+
+    public static void main(String[] args) throws SQLException {
+        try (ConfigurableApplicationContext applicationContext = 
SpringApplication.run(SPIBasedShardingSpringBootMybatisExample.class, args)) {
+            
ExampleExecuteTemplate.run(applicationContext.getBean(ExampleService.class));
+        }
+    }
+}
diff --git 
a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/java/org/apache/shardingsphere/example/extension/spibased/sharding/spring/boot/mybatis/fixture/SPIBasedDatasourceStandardShardingAlgorithmFixture.java
 
b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-
 [...]
new file mode 100644
index 0000000..5e2bf4b
--- /dev/null
+++ 
b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/java/org/apache/shardingsphere/example/extension/spibased/sharding/spring/boot/mybatis/fixture/SPIBasedDatasourceStandardShardingAlgorithmFixture.java
@@ -0,0 +1,54 @@
+/*
+ * 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.
+ */
+
+package 
org.apache.shardingsphere.example.extension.spibased.sharding.spring.boot.mybatis.fixture;
+
+import 
org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
+import 
org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
+import 
org.apache.shardingsphere.sharding.api.sharding.standard.StandardShardingAlgorithm;
+
+import java.util.Collection;
+
+public final class SPIBasedDatasourceStandardShardingAlgorithmFixture 
implements StandardShardingAlgorithm<Integer> {
+
+    @Override
+    public String doSharding(final Collection<String> dataSourceNames, final 
PreciseShardingValue<Integer> shardingValue) {
+        for (String each : dataSourceNames) {
+            if (each.endsWith(shardingSuffix(shardingValue.getValue()))) {
+                return each;
+            }
+        }
+        return null;
+    }
+
+    private String shardingSuffix(Integer shardingValue) {
+        return "-" + (shardingValue % 2);
+    }
+
+    @Override
+    public Collection<String> doSharding(Collection<String> 
availableTargetNames, RangeShardingValue<Integer> shardingValue) {
+        return availableTargetNames;
+    }
+
+    @Override
+    public void init() {}
+
+    @Override
+    public String getType() {
+        return "DATASOURCE_SPI_BASED";
+    }
+}
diff --git 
a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/java/org/apache/shardingsphere/example/extension/spibased/sharding/spring/boot/mybatis/fixture/SPIBasedOrderItemStandardShardingAlgorithmFixture.java
 
b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-s
 [...]
new file mode 100644
index 0000000..beb1e3c
--- /dev/null
+++ 
b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/java/org/apache/shardingsphere/example/extension/spibased/sharding/spring/boot/mybatis/fixture/SPIBasedOrderItemStandardShardingAlgorithmFixture.java
@@ -0,0 +1,55 @@
+/*
+ * 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.
+ */
+
+package 
org.apache.shardingsphere.example.extension.spibased.sharding.spring.boot.mybatis.fixture;
+
+import 
org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
+import 
org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
+import 
org.apache.shardingsphere.sharding.api.sharding.standard.StandardShardingAlgorithm;
+
+import java.util.Collection;
+
+public final class SPIBasedOrderItemStandardShardingAlgorithmFixture 
implements StandardShardingAlgorithm<Long> {
+
+    @Override
+    public String doSharding(final Collection<String> availableTargetNames, 
final PreciseShardingValue<Long> shardingValue) {
+        for (String each : availableTargetNames) {
+            if (each.endsWith(shardingSuffix(shardingValue.getValue()))) {
+                return each;
+            }
+        }
+        return null;
+    }
+
+    private String shardingSuffix(Long shardingValue) {
+        return "_" + (shardingValue % 2);
+    }
+
+    @Override
+    public Collection<String> doSharding
+            (Collection<String> availableTargetNames, RangeShardingValue<Long> 
shardingValue) {
+        return availableTargetNames;
+    }
+
+    @Override
+    public void init() {}
+
+    @Override
+    public String getType() {
+        return "T_ORDER_ITEM_SPI_BASED";
+    }
+}
diff --git 
a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/java/org/apache/shardingsphere/example/extension/spibased/sharding/spring/boot/mybatis/fixture/SPIBasedOrderStandardShardingAlgorithmFixture.java
 
b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-shard
 [...]
new file mode 100644
index 0000000..490f1e2
--- /dev/null
+++ 
b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/java/org/apache/shardingsphere/example/extension/spibased/sharding/spring/boot/mybatis/fixture/SPIBasedOrderStandardShardingAlgorithmFixture.java
@@ -0,0 +1,54 @@
+/*
+ * 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.
+ */
+
+package 
org.apache.shardingsphere.example.extension.spibased.sharding.spring.boot.mybatis.fixture;
+
+import 
org.apache.shardingsphere.sharding.api.sharding.standard.PreciseShardingValue;
+import 
org.apache.shardingsphere.sharding.api.sharding.standard.RangeShardingValue;
+import 
org.apache.shardingsphere.sharding.api.sharding.standard.StandardShardingAlgorithm;
+
+import java.util.Collection;
+
+public final class SPIBasedOrderStandardShardingAlgorithmFixture implements 
StandardShardingAlgorithm<Long> {
+
+    @Override
+    public String doSharding(final Collection<String> availableTargetNames, 
final PreciseShardingValue<Long> shardingValue) {
+        for (String each : availableTargetNames) {
+            if (each.endsWith(shardingSuffix(shardingValue.getValue()))) {
+                return each;
+            }
+        }
+        return null;
+    }
+
+    private String shardingSuffix(Long shardingValue) {
+        return "_" + (shardingValue % 2);
+    }
+
+    @Override
+    public Collection<String> doSharding(Collection<String> 
availableTargetNames, RangeShardingValue<Long> shardingValue) {
+        return availableTargetNames;
+    }
+
+    @Override
+    public void init() {}
+
+    @Override
+    public String getType() {
+        return "T_ORDER_SPI_BASED";
+    }
+}
diff --git 
a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/pom.xml
 
b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/resources/META-INF/mybatis-config.xml
similarity index 52%
copy from 
examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/pom.xml
copy to 
examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/resources/META-INF/mybatis-config.xml
index bc2b0a9..84a6692 100644
--- 
a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/pom.xml
+++ 
b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/resources/META-INF/mybatis-config.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?>
+<?xml version="1.0" encoding="UTF-8" ?>
 <!--
   ~ Licensed to the Apache Software Foundation (ASF) under one or more
   ~ contributor license agreements.  See the NOTICE file distributed with
@@ -16,20 +16,13 @@
   ~ limitations under the License.
   -->
 
-<project xmlns="http://maven.apache.org/POM/4.0.0";
-         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
-    <modelVersion>4.0.0</modelVersion>
-    <parent>
-        <groupId>org.apache.shardingsphere.example</groupId>
-        <artifactId>custom-sharding-algortihm-example</artifactId>
-        <version>${revision}</version>
-    </parent>
-    <artifactId>spi-based-sharding-algorithm-example</artifactId>
-    <name>${project.artifactId}</name>
-    <packaging>pom</packaging>
-    
-    <modules>
-        <module>spi-based-sharding-raw-jdbc-example</module>
-    </modules>
-</project>
+<!DOCTYPE configuration
+        PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-config.dtd";>
+<configuration>
+    <mappers>
+        <mapper resource="META-INF/mappers/AddressMapper.xml"/>
+        <mapper resource="META-INF/mappers/OrderMapper.xml"/>
+        <mapper resource="META-INF/mappers/OrderItemMapper.xml"/>
+    </mappers>
+</configuration>
diff --git 
a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/resources/META-INF/services/org.apache.shardingsphere.sharding.spi.ShardingAlgorithm
 
b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-
 [...]
new file mode 100644
index 0000000..cfece13
--- /dev/null
+++ 
b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/resources/META-INF/services/org.apache.shardingsphere.sharding.spi.ShardingAlgorithm
@@ -0,0 +1,20 @@
+#
+# 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.
+#
+
+org.apache.shardingsphere.example.extension.spibased.sharding.spring.boot.mybatis.fixture.SPIBasedOrderStandardShardingAlgorithmFixture
+org.apache.shardingsphere.example.extension.spibased.sharding.spring.boot.mybatis.fixture.SPIBasedOrderItemStandardShardingAlgorithmFixture
+org.apache.shardingsphere.example.extension.spibased.sharding.spring.boot.mybatis.fixture.SPIBasedDatasourceStandardShardingAlgorithmFixture
diff --git 
a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-auto-tables.properties
 
b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/resources/appl
 [...]
new file mode 100644
index 0000000..5a42063
--- /dev/null
+++ 
b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-auto-tables.properties
@@ -0,0 +1,55 @@
+#
+# 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.
+#
+
+spring.shardingsphere.datasource.names=ds-0,ds-1
+
+spring.shardingsphere.datasource.ds-0.jdbc-url=jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+spring.shardingsphere.datasource.ds-0.type=com.zaxxer.hikari.HikariDataSource
+spring.shardingsphere.datasource.ds-0.driver-class-name=com.mysql.jdbc.Driver
+spring.shardingsphere.datasource.ds-0.username=root
+spring.shardingsphere.datasource.ds-0.password=
+
+spring.shardingsphere.datasource.ds-1.jdbc-url=jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+spring.shardingsphere.datasource.ds-1.type=com.zaxxer.hikari.HikariDataSource
+spring.shardingsphere.datasource.ds-1.driver-class-name=com.mysql.jdbc.Driver
+spring.shardingsphere.datasource.ds-1.username=root
+spring.shardingsphere.datasource.ds-1.password=
+
+spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-column=user_id
+spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-algorithm-name=database-inline
+spring.shardingsphere.rules.sharding.binding-tables[0]=t_order,t_order_item
+
+spring.shardingsphere.rules.sharding.autotables.t_order.actual-datasources=ds-${0..1}
+
+spring.shardingsphere.rules.sharding.auto-tables.t_order.sharding-strategy.standard.sharding-column=order_id
+spring.shardingsphere.rules.sharding.auto-tables.t_order.sharding-strategy.standard.sharding-algorithm-name=auto-mod
+
+spring.shardingsphere.rules.sharding.auto-tables.t_order.key-generate-strategy.column=order_id
+spring.shardingsphere.rules.sharding.auto-tables.t_order.key-generate-strategy.key-generator-name=snowflake
+
+spring.shardingsphere.rules.sharding.auto-tables.t_order_item.actual-datasources=ds-${0..1}
+
+spring.shardingsphere.rules.sharding.auto-tables.t_order_item.sharding-strategy.standard.sharding-column=order_item_id
+spring.shardingsphere.rules.sharding.auto-tables.t_order_item.sharding-strategy.standard.sharding-algorithm-name=auto-mod
+
+spring.shardingsphere.rules.sharding.auto-tables.t_order_item.key-generate-strategy.column=order_item_id
+spring.shardingsphere.rules.sharding.auto-tables.t_order_item.key-generate-strategy.key-generator-name=snowflake
+
+spring.shardingsphere.rules.sharding.sharding-algorithms.auto-mod.type=mod
+spring.shardingsphere.rules.sharding.sharding-algorithms.auto-mod.props.sharding-count=4
+
+spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE
diff --git 
a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-databases-tables.properties
 
b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/resources
 [...]
new file mode 100644
index 0000000..17e4b0e
--- /dev/null
+++ 
b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-databases-tables.properties
@@ -0,0 +1,59 @@
+#
+# 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.
+#
+
+spring.shardingsphere.mode.type=Standalone
+spring.shardingsphere.mode.repository.type=File
+spring.shardingsphere.mode.overwrite=true
+
+spring.shardingsphere.datasource.names=ds-0,ds-1
+
+spring.shardingsphere.datasource.ds-0.jdbc-url=jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+spring.shardingsphere.datasource.ds-0.type=com.zaxxer.hikari.HikariDataSource
+spring.shardingsphere.datasource.ds-0.driver-class-name=com.mysql.jdbc.Driver
+spring.shardingsphere.datasource.ds-0.username=root
+spring.shardingsphere.datasource.ds-0.password=
+
+spring.shardingsphere.datasource.ds-1.jdbc-url=jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+spring.shardingsphere.datasource.ds-1.type=com.zaxxer.hikari.HikariDataSource
+spring.shardingsphere.datasource.ds-1.driver-class-name=com.mysql.jdbc.Driver
+spring.shardingsphere.datasource.ds-1.username=root
+spring.shardingsphere.datasource.ds-1.password=
+
+spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-column=user_id
+spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-algorithm-name=datasource-spi-based
+spring.shardingsphere.rules.sharding.binding-tables[0]=t_order,t_order_item
+spring.shardingsphere.rules.sharding.broadcast-tables=t_address
+
+spring.shardingsphere.rules.sharding.tables.t_order.actual-data-nodes=ds-$->{0..1}.t_order_$->{0..1}
+spring.shardingsphere.rules.sharding.tables.t_order.table-strategy.standard.sharding-column=order_id
+spring.shardingsphere.rules.sharding.tables.t_order.table-strategy.standard.sharding-algorithm-name=t-order-spi-based
+
+spring.shardingsphere.rules.sharding.tables.t_order.key-generate-strategy.column=order_id
+spring.shardingsphere.rules.sharding.tables.t_order.key-generate-strategy.key-generator-name=snowflake
+
+spring.shardingsphere.rules.sharding.tables.t_order_item.actual-data-nodes=ds-$->{0..1}.t_order_item_$->{0..1}
+spring.shardingsphere.rules.sharding.tables.t_order_item.table-strategy.standard.sharding-column=order_id
+spring.shardingsphere.rules.sharding.tables.t_order_item.table-strategy.standard.sharding-algorithm-name=t-order-item-spi-based
+
+spring.shardingsphere.rules.sharding.tables.t_order_item.key-generate-strategy.column=order_item_id
+spring.shardingsphere.rules.sharding.tables.t_order_item.key-generate-strategy.key-generator-name=snowflake
+
+spring.shardingsphere.rules.sharding.sharding-algorithms.datasource-spi-based.type=DATASOURCE_SPI_BASED
+spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-spi-based.type=T_ORDER_SPI_BASED
+spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-item-spi-based.type=T_ORDER_ITEM_SPI_BASED
+
+spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE
diff --git 
a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-databases.properties
 
b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/resources/applic
 [...]
new file mode 100644
index 0000000..d862b38
--- /dev/null
+++ 
b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-databases.properties
@@ -0,0 +1,49 @@
+#
+# 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.
+#
+
+spring.shardingsphere.datasource.names=ds-0,ds-1
+
+spring.shardingsphere.datasource.ds-0.jdbc-url=jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+spring.shardingsphere.datasource.ds-0.type=com.zaxxer.hikari.HikariDataSource
+spring.shardingsphere.datasource.ds-0.driver-class-name=com.mysql.jdbc.Driver
+spring.shardingsphere.datasource.ds-0.username=root
+spring.shardingsphere.datasource.ds-0.password=
+
+spring.shardingsphere.datasource.ds-1.jdbc-url=jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+spring.shardingsphere.datasource.ds-1.type=com.zaxxer.hikari.HikariDataSource
+spring.shardingsphere.datasource.ds-1.driver-class-name=com.mysql.jdbc.Driver
+spring.shardingsphere.datasource.ds-1.username=root
+spring.shardingsphere.datasource.ds-1.password=
+
+spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-column=user_id
+spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-algorithm-name=datasource-spi-based
+spring.shardingsphere.rules.sharding.binding-tables[0]=t_order,t_order_item
+spring.shardingsphere.rules.sharding.broadcast-tables=t_address
+
+spring.shardingsphere.rules.sharding.tables.t_order.actual-data-nodes=ds-$->{0..1}.t_order
+
+spring.shardingsphere.rules.sharding.tables.t_order.key-generate-strategy.column=order_id
+spring.shardingsphere.rules.sharding.tables.t_order.key-generate-strategy.key-generator-name=snowflake
+
+spring.shardingsphere.rules.sharding.tables.t_order_item.actual-data-nodes=ds-$->{0..1}.t_order_item
+
+spring.shardingsphere.rules.sharding.tables.t_order_item.key-generate-strategy.column=order_item_id
+spring.shardingsphere.rules.sharding.tables.t_order_item.key-generate-strategy.key-generator-name=snowflake
+
+spring.shardingsphere.rules.sharding.sharding-algorithms.datasource-spi-based.type=DATASOURCE_SPI_BASED
+
+spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE
diff --git 
a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-tables.properties
 
b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/resources/applicati
 [...]
new file mode 100644
index 0000000..b973e44
--- /dev/null
+++ 
b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-tables.properties
@@ -0,0 +1,48 @@
+#
+# 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.
+#
+
+spring.shardingsphere.mode.type=Memory
+
+spring.shardingsphere.datasource.names=ds
+
+spring.shardingsphere.datasource.ds.type=com.zaxxer.hikari.HikariDataSource
+spring.shardingsphere.datasource.ds.driver-class-name=com.mysql.jdbc.Driver
+spring.shardingsphere.datasource.ds.jdbc-url=jdbc:mysql://localhost:3306/demo_ds?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+spring.shardingsphere.datasource.ds.username=root
+spring.shardingsphere.datasource.ds.password=123456789
+
+spring.shardingsphere.rules.sharding.tables.t_order.actual-data-nodes=ds.t_order_$->{0..1}
+spring.shardingsphere.rules.sharding.tables.t_order.table-strategy.standard.sharding-column=order_id
+spring.shardingsphere.rules.sharding.tables.t_order.table-strategy.standard.sharding-algorithm-name=t-order-spi-based
+
+spring.shardingsphere.rules.sharding.tables.t_order.key-generate-strategy.column=order_id
+spring.shardingsphere.rules.sharding.tables.t_order.key-generate-strategy.key-generator-name=snowflake
+
+spring.shardingsphere.rules.sharding.tables.t_order_item.actual-data-nodes=ds.t_order_item_$->{0..1}
+spring.shardingsphere.rules.sharding.tables.t_order_item.table-strategy.standard.sharding-column=order_id
+spring.shardingsphere.rules.sharding.tables.t_order_item.table-strategy.standard.sharding-algorithm-name=t-order-item-spi-based
+
+spring.shardingsphere.rules.sharding.tables.t_order_item.key-generate-strategy.column=order_item_id
+spring.shardingsphere.rules.sharding.tables.t_order_item.key-generate-strategy.key-generator-name=snowflake
+
+spring.shardingsphere.rules.sharding.binding-tables[0]=t_order,t_order_item
+spring.shardingsphere.rules.sharding.broadcast-tables=t_address
+
+spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-spi-based.type=T_ORDER_SPI_BASED
+spring.shardingsphere.rules.sharding.sharding-algorithms.t-order-item-spi-based.type=T_ORDER_ITEM_SPI_BASED
+
+spring.shardingsphere.rules.sharding.key-generators.snowflake.type=SNOWFLAKE
diff --git 
a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/resources/application.properties
 
b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/resources/application.properties
new file mode 100644
index 0000000..c09554c
--- /dev/null
+++ 
b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/resources/application.properties
@@ -0,0 +1,23 @@
+#
+# 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.
+#
+
+mybatis.config-location=classpath:META-INF/mybatis-config.xml
+
+#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/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/pom.xml
 
b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/resources/logback.xml
similarity index 55%
copy from 
examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/pom.xml
copy to 
examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/resources/logback.xml
index bc2b0a9..cf5fbce 100644
--- 
a/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/pom.xml
+++ 
b/examples/shardingsphere-jdbc-example/single-feature-example/extension-example/custom-sharding-algortihm-example/spi-based-sharding-algorithm-example/spi-based-sharding-spring-boot-mybatis-example/src/main/resources/logback.xml
@@ -16,20 +16,19 @@
   ~ limitations under the License.
   -->
 
-<project xmlns="http://maven.apache.org/POM/4.0.0";
-         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
-    <modelVersion>4.0.0</modelVersion>
-    <parent>
-        <groupId>org.apache.shardingsphere.example</groupId>
-        <artifactId>custom-sharding-algortihm-example</artifactId>
-        <version>${revision}</version>
-    </parent>
-    <artifactId>spi-based-sharding-algorithm-example</artifactId>
-    <name>${project.artifactId}</name>
-    <packaging>pom</packaging>
+<configuration>
+    <property name="log.context.name" 
value="spi-based-sharding-spring-boot-mybatis-example" />
+    <property name="log.charset" value="UTF-8" />
+    <property name="log.pattern" value="[%-5level] %date --%thread-- [%logger] 
%msg %n" />
+    <contextName>${log.context.name}</contextName>
     
-    <modules>
-        <module>spi-based-sharding-raw-jdbc-example</module>
-    </modules>
-</project>
+    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder charset="${log.charset}">
+            <pattern>${log.pattern}</pattern>
+        </encoder>
+    </appender>
+    <root>
+        <level value="INFO" />
+        <appender-ref ref="STDOUT" />
+    </root>
+</configuration>

Reply via email to