You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2021/12/09 15:30:42 UTC
[shardingsphere] branch master updated: Add shadow spring boot starter example and adjust template (#14023)
This is an automated email from the ASF dual-hosted git repository.
zhangliang 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 d33ea03 Add shadow spring boot starter example and adjust template (#14023)
d33ea03 is described below
commit d33ea03f32d4ac97d67fd2517307b4d85b15c8c7
Author: Guocheng Tang <to...@qq.com>
AuthorDate: Thu Dec 9 23:29:53 2021 +0800
Add shadow spring boot starter example and adjust template (#14023)
---
...or.java => SpringBootStarterJDBCGenerator.java} | 16 +--
...tor.java => SpringBootStarterJpaGenerator.java} | 16 +--
...java => SpringBootStarterMybatisGenerator.java} | 24 ++--
.../data-model.yaml | 4 +-
.../data-model.yaml | 4 +-
.../data-model.yaml | 4 +-
.../src/main/resources/template/Example.ftl | 16 +--
.../resources/template/properties/application.ftl | 4 +
.../template/properties/shadowApplication.ftl | 41 ++++++
.../pom.xml | 3 +
.../pom.xml | 24 ++--
...oryLocalShadowSpringBootStarterJdbcExample.java | 34 +++++
...lShadowSpringBootStarterJdbcExampleService.java | 153 +++++++++++++++++++++
.../spring/boot/starter/jdbc/entity/User.java | 60 ++++++++
.../src/main/resources/application.properties | 58 ++++++++
.../src/main/resources/logback.xml | 34 +++++
.../pom.xml | 33 +++--
...moryLocalShadowSpringBootStarterJpaExample.java | 36 +++++
...alShadowSpringBootStarterJpaExampleService.java | 71 ++++++++++
...yLocalShadowSpringBootStarterJpaRepository.java | 50 +++++++
.../spring/boot/starter/jpa/entity/User.java | 73 ++++++++++
.../src/main/resources/application.properties | 62 +++++++++
.../src/main/resources/logback.xml | 34 +++++
.../pom.xml | 23 ++--
...LocalShadowSpringBootStarterMybatisExample.java | 36 +++++
...adowSpringBootStarterMybatisExampleService.java | 103 ++++++++++++++
.../spring/boot/starter/mybatis/entity/User.java | 60 ++++++++
.../starter/mybatis/repository/UserRepository.java | 39 ++++++
.../src/main/resources/application.properties | 60 ++++++++
.../src/main/resources/logback.xml | 34 +++++
.../src/main/resources/mappers/UserMapper.xml | 51 +++++++
.../pom.xml | 2 +-
32 files changed, 1185 insertions(+), 77 deletions(-)
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/SpringbootStarterJDBCGenerator.java b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/SpringBootStarterJDBCGenerator.java
similarity index 74%
rename from examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/SpringbootStarterJDBCGenerator.java
rename to examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/SpringBootStarterJDBCGenerator.java
index 2f60a3e..c14de0e 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/SpringbootStarterJDBCGenerator.java
+++ b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/SpringBootStarterJDBCGenerator.java
@@ -23,7 +23,7 @@ import java.util.Map;
/**
* springboot starter jdbc generator.
*/
-public final class SpringbootStarterJDBCGenerator extends ExampleGenerateEngine {
+public final class SpringBootStarterJDBCGenerator extends ExampleGenerateEngine {
private static final Map<String, String> RENAME_TEMPLATE_MAP = new HashMap<>();
private static final Map<String, String> UN_NAME_TEMPLATE_MAP = new HashMap<>();
@@ -33,27 +33,27 @@ public final class SpringbootStarterJDBCGenerator extends ExampleGenerateEngine
RENAME_TEMPLATE_MAP.put("Example", "Example.ftl");
RENAME_TEMPLATE_MAP.put("ExampleService", "jdbc/ExampleService.ftl");
- UN_NAME_TEMPLATE_MAP.put("entity/Order", "entity/Order.java");
- UN_NAME_TEMPLATE_MAP.put("entity/OrderItem", "entity/OrderItem.java");
+ //UN_NAME_TEMPLATE_MAP.put("entity/Order", "entity/Order.java");
+ //UN_NAME_TEMPLATE_MAP.put("entity/OrderItem", "entity/OrderItem.java");
UN_NAME_TEMPLATE_MAP.put("entity/User", "entity/User.java");
- UN_NAME_TEMPLATE_MAP.put("TestQueryAssistedShardingEncryptAlgorithm", "TestQueryAssistedShardingEncryptAlgorithm.java");
+ //UN_NAME_TEMPLATE_MAP.put("TestQueryAssistedShardingEncryptAlgorithm", "TestQueryAssistedShardingEncryptAlgorithm.java");
RESOURCE_TEMPLATE_MAP.put("log/logback", "logback.xml");
- RESOURCE_TEMPLATE_MAP.put("spi/encryptAlgorithm", "META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm");
+ //RESOURCE_TEMPLATE_MAP.put("spi/encryptAlgorithm", "META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm");
RESOURCE_TEMPLATE_MAP.put("properties/application", "application.properties");
}
- public SpringbootStarterJDBCGenerator() {
+ public SpringBootStarterJDBCGenerator() {
super(RENAME_TEMPLATE_MAP, UN_NAME_TEMPLATE_MAP, RESOURCE_TEMPLATE_MAP);
}
@Override
protected String getGenerator() {
- return "springboot-starter-jdbc";
+ return "spring-boot-starter-jdbc";
}
public static void main(String[] args) {
- SpringbootStarterJDBCGenerator generator = new SpringbootStarterJDBCGenerator();
+ SpringBootStarterJDBCGenerator generator = new SpringBootStarterJDBCGenerator();
generator.exec();
}
}
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/SpringbootStarterJpaGenerator.java b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/SpringBootStarterJpaGenerator.java
similarity index 75%
rename from examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/SpringbootStarterJpaGenerator.java
rename to examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/SpringBootStarterJpaGenerator.java
index 293548b..ee7b38f 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/SpringbootStarterJpaGenerator.java
+++ b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/SpringBootStarterJpaGenerator.java
@@ -23,7 +23,7 @@ import java.util.Map;
/**
* spring boot starter jpa generator.
*/
-public final class SpringbootStarterJpaGenerator extends ExampleGenerateEngine {
+public final class SpringBootStarterJpaGenerator extends ExampleGenerateEngine {
private static final Map<String, String> RENAME_TEMPLATE_MAP = new HashMap<>();
private static final Map<String, String> UN_NAME_TEMPLATE_MAP = new HashMap<>();
@@ -34,28 +34,28 @@ public final class SpringbootStarterJpaGenerator extends ExampleGenerateEngine {
RENAME_TEMPLATE_MAP.put("ExampleService", "jpa/ExampleService.ftl");
RENAME_TEMPLATE_MAP.put("Repository", "jpa/Repository.ftl");
- UN_NAME_TEMPLATE_MAP.put("entity/Order", "entity/Order.java");
- UN_NAME_TEMPLATE_MAP.put("entity/OrderItem", "entity/OrderItem.java");
+ //UN_NAME_TEMPLATE_MAP.put("entity/Order", "entity/Order.java");
+ //UN_NAME_TEMPLATE_MAP.put("entity/OrderItem", "entity/OrderItem.java");
UN_NAME_TEMPLATE_MAP.put("entity/User", "entity/User.java");
- UN_NAME_TEMPLATE_MAP.put("TestQueryAssistedShardingEncryptAlgorithm", "TestQueryAssistedShardingEncryptAlgorithm.java");
+ //UN_NAME_TEMPLATE_MAP.put("TestQueryAssistedShardingEncryptAlgorithm", "TestQueryAssistedShardingEncryptAlgorithm.java");
RESOURCE_TEMPLATE_MAP.put("log/logback", "logback.xml");
- RESOURCE_TEMPLATE_MAP.put("spi/encryptAlgorithm", "META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm");
+ //RESOURCE_TEMPLATE_MAP.put("spi/encryptAlgorithm", "META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm");
RESOURCE_TEMPLATE_MAP.put("properties/application", "application.properties");
}
- public SpringbootStarterJpaGenerator() {
+ public SpringBootStarterJpaGenerator() {
super(RENAME_TEMPLATE_MAP, UN_NAME_TEMPLATE_MAP, RESOURCE_TEMPLATE_MAP);
}
@Override
protected String getGenerator() {
- return "springboot-starter-jpa";
+ return "spring-boot-starter-jpa";
}
public static void main(String[] args) {
- SpringbootStarterJpaGenerator generator = new SpringbootStarterJpaGenerator();
+ SpringBootStarterJpaGenerator generator = new SpringBootStarterJpaGenerator();
generator.exec();
}
}
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/SpringbootStarterMybatisGenerator.java b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/SpringBootStarterMybatisGenerator.java
similarity index 65%
rename from examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/SpringbootStarterMybatisGenerator.java
rename to examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/SpringBootStarterMybatisGenerator.java
index e141bfd..9224379 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/SpringbootStarterMybatisGenerator.java
+++ b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/java/org/apache/sharding/example/engine/SpringBootStarterMybatisGenerator.java
@@ -23,7 +23,7 @@ import java.util.Map;
/**
* spring boot starter mybatis generator.
*/
-public final class SpringbootStarterMybatisGenerator extends ExampleGenerateEngine {
+public final class SpringBootStarterMybatisGenerator extends ExampleGenerateEngine {
private static final Map<String, String> RENAME_TEMPLATE_MAP = new HashMap<>();
private static final Map<String, String> UN_NAME_TEMPLATE_MAP = new HashMap<>();
@@ -33,33 +33,33 @@ public final class SpringbootStarterMybatisGenerator extends ExampleGenerateEngi
RENAME_TEMPLATE_MAP.put("Example", "Example.ftl");
RENAME_TEMPLATE_MAP.put("ExampleService", "ExampleService.ftl");
- UN_NAME_TEMPLATE_MAP.put("entity/Order", "entity/Order.java");
- UN_NAME_TEMPLATE_MAP.put("entity/OrderItem", "entity/OrderItem.java");
- UN_NAME_TEMPLATE_MAP.put("mybatis/OrderItemRepository", "repository/OrderItemRepository.java");
- UN_NAME_TEMPLATE_MAP.put("mybatis/OrderRepository", "repository/OrderRepository.java");
+ //UN_NAME_TEMPLATE_MAP.put("entity/Order", "entity/Order.java");
+ //UN_NAME_TEMPLATE_MAP.put("entity/OrderItem", "entity/OrderItem.java");
+ //UN_NAME_TEMPLATE_MAP.put("mybatis/OrderItemRepository", "repository/OrderItemRepository.java");
+ //UN_NAME_TEMPLATE_MAP.put("mybatis/OrderRepository", "repository/OrderRepository.java");
UN_NAME_TEMPLATE_MAP.put("mybatis/UserRepository", "repository/UserRepository.java");
UN_NAME_TEMPLATE_MAP.put("entity/User", "entity/User.java");
- UN_NAME_TEMPLATE_MAP.put("TestQueryAssistedShardingEncryptAlgorithm", "TestQueryAssistedShardingEncryptAlgorithm.java");
+ //UN_NAME_TEMPLATE_MAP.put("TestQueryAssistedShardingEncryptAlgorithm", "TestQueryAssistedShardingEncryptAlgorithm.java");
RESOURCE_TEMPLATE_MAP.put("log/logback", "logback.xml");
- RESOURCE_TEMPLATE_MAP.put("spi/encryptAlgorithm", "META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm");
- RESOURCE_TEMPLATE_MAP.put("mappers/OrderItemMapper", "mappers/OrderItemMapper.xml");
- RESOURCE_TEMPLATE_MAP.put("mappers/OrderMapper", "mappers/OrderMapper.xml");
+ //RESOURCE_TEMPLATE_MAP.put("spi/encryptAlgorithm", "META-INF/services/org.apache.shardingsphere.encrypt.spi.EncryptAlgorithm");
+ //RESOURCE_TEMPLATE_MAP.put("mappers/OrderItemMapper", "mappers/OrderItemMapper.xml");
+ //RESOURCE_TEMPLATE_MAP.put("mappers/OrderMapper", "mappers/OrderMapper.xml");
RESOURCE_TEMPLATE_MAP.put("mappers/UserMapper", "mappers/UserMapper.xml");
RESOURCE_TEMPLATE_MAP.put("properties/application", "application.properties");
}
- public SpringbootStarterMybatisGenerator() {
+ public SpringBootStarterMybatisGenerator() {
super(RENAME_TEMPLATE_MAP, UN_NAME_TEMPLATE_MAP, RESOURCE_TEMPLATE_MAP);
}
@Override
protected String getGenerator() {
- return "springboot-starter-mybatis";
+ return "spring-boot-starter-mybatis";
}
public static void main(String[] args) {
- SpringbootStarterMybatisGenerator generator = new SpringbootStarterMybatisGenerator();
+ SpringBootStarterMybatisGenerator generator = new SpringBootStarterMybatisGenerator();
generator.exec();
}
}
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/springboot-starter-jdbc/data-model.yaml b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/spring-boot-starter-jdbc/data-model.yaml
similarity index 94%
rename from examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/springboot-starter-jdbc/data-model.yaml
rename to examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/spring-boot-starter-jdbc/data-model.yaml
index 9a18157..07aed2e 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/springboot-starter-jdbc/data-model.yaml
+++ b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/spring-boot-starter-jdbc/data-model.yaml
@@ -17,6 +17,6 @@
mode: memory
transaction: local
-feature: encrypt
-framework: springboot-starter-jdbc
+feature: shadow
+framework: spring-boot-starter-jdbc
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/springboot-starter-jpa/data-model.yaml b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/spring-boot-starter-jpa/data-model.yaml
similarity index 94%
rename from examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/springboot-starter-jpa/data-model.yaml
rename to examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/spring-boot-starter-jpa/data-model.yaml
index 72d371a..23a1a30 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/springboot-starter-jpa/data-model.yaml
+++ b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/spring-boot-starter-jpa/data-model.yaml
@@ -17,6 +17,6 @@
mode: memory
transaction: local
-feature: encrypt
-framework: springboot-starter-jpa
+feature: shadow
+framework: spring-boot-starter-jpa
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/springboot-starter-mybatis/data-model.yaml b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/spring-boot-starter-mybatis/data-model.yaml
similarity index 93%
rename from examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/springboot-starter-mybatis/data-model.yaml
rename to examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/spring-boot-starter-mybatis/data-model.yaml
index 6df8949..7e7008f 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/springboot-starter-mybatis/data-model.yaml
+++ b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/dataModel/spring-boot-starter-mybatis/data-model.yaml
@@ -17,6 +17,6 @@
mode: memory
transaction: local
-feature: encrypt
-framework: springboot-starter-mybatis
+feature: shadow
+framework: spring-boot-starter-mybatis
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/Example.ftl b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/Example.ftl
index 9ca339c..163b828 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/Example.ftl
+++ b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/Example.ftl
@@ -17,10 +17,10 @@
package org.apache.shardingsphere.example.${feature?replace('-', '.')}.${framework?replace('-', '.')};
-<#if framework?contains("springboot")>
-<#if framework=="springboot-starter-mybatis">
+<#if framework?contains("spring-boot")>
+<#if framework=="spring-boot-starter-mybatis">
import org.mybatis.spring.annotation.MapperScan;
-<#elseif framework=="springboot-starter-jpa">
+<#elseif framework=="spring-boot-starter-jpa">
import org.springframework.boot.autoconfigure.domain.EntityScan;
</#if>
import org.springframework.boot.SpringApplication;
@@ -43,13 +43,13 @@ import java.sql.SQLException;
<#list feature?split("-") as feature1>
<#assign featureName=featureName + feature1?cap_first>
</#list>
-<#if framework=="springboot-starter-mybatis">
-@MapperScan("org.apache.shardingsphere.example.${feature?replace('-', '.')}.springboot.starter.mybatis.repository")
+<#if framework=="spring-boot-starter-mybatis">
+@MapperScan("org.apache.shardingsphere.example.${feature?replace('-', '.')}.spring.boot.starter.mybatis.repository")
</#if>
-<#if framework=="springboot-starter-jpa">
-@EntityScan(basePackages = "org.apache.shardingsphere.example.${feature?replace('-', '.')}.springboot.starter.jpa.entity")
+<#if framework=="spring-boot-starter-jpa">
+@EntityScan(basePackages = "org.apache.shardingsphere.example.${feature?replace('-', '.')}.spring.boot.starter.jpa.entity")
</#if>
-<#if framework?contains("springboot")>
+<#if framework?contains("spring-boot")>
@SpringBootApplication
</#if>
public class ${mode?cap_first}${transaction?cap_first}${featureName}${frameworkName}Example {
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/properties/application.ftl b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/properties/application.ftl
index dfff3a1..19662fa 100644
--- a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/properties/application.ftl
+++ b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/properties/application.ftl
@@ -52,4 +52,8 @@ spring.shardingsphere.datasource.names=ds-0,ds-1,ds-2
spring.shardingsphere.datasource.names=ds-0
<#include "encryptApplication.ftl">
+<#elseif feature=="shadow">
+spring.shardingsphere.datasource.names=ds-0,ds-1
+
+ <#include "shadowApplication.ftl">
</#if>
diff --git a/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/properties/shadowApplication.ftl b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/properties/shadowApplication.ftl
new file mode 100644
index 0000000..020d007
--- /dev/null
+++ b/examples/shardingsphere-sample/shardingsphere-example-engine/src/main/resources/template/properties/shadowApplication.ftl
@@ -0,0 +1,41 @@
+<#--
+ ~ 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.rules.shadow.enable=true
+spring.shardingsphere.rules.shadow.data-sources.shadow-data-source.source-data-source-name=ds-0
+spring.shardingsphere.rules.shadow.data-sources.shadow-data-source.shadow-data-source-name=ds-1
+
+spring.shardingsphere.rules.shadow.tables.t_user.data-source-names=shadow-data-source
+spring.shardingsphere.rules.shadow.tables.t_user.shadow-algorithm-names=user-id-insert-match-algorithm,user-id-delete-match-algorithm,user-id-select-match-algorithm,simple-hint-algorithm
+
+spring.shardingsphere.rules.shadow.shadow-algorithms.user-id-insert-match-algorithm.type=VALUE_MATCH
+spring.shardingsphere.rules.shadow.shadow-algorithms.user-id-insert-match-algorithm.props.operation=insert
+spring.shardingsphere.rules.shadow.shadow-algorithms.user-id-insert-match-algorithm.props.column=user_type
+spring.shardingsphere.rules.shadow.shadow-algorithms.user-id-insert-match-algorithm.props.value=1
+
+spring.shardingsphere.rules.shadow.shadow-algorithms.user-id-delete-match-algorithm.type=VALUE_MATCH
+spring.shardingsphere.rules.shadow.shadow-algorithms.user-id-delete-match-algorithm.props.operation=delete
+spring.shardingsphere.rules.shadow.shadow-algorithms.user-id-delete-match-algorithm.props.column=user_type
+spring.shardingsphere.rules.shadow.shadow-algorithms.user-id-delete-match-algorithm.props.value=1
+
+spring.shardingsphere.rules.shadow.shadow-algorithms.user-id-select-match-algorithm.type=VALUE_MATCH
+spring.shardingsphere.rules.shadow.shadow-algorithms.user-id-select-match-algorithm.props.operation=select
+spring.shardingsphere.rules.shadow.shadow-algorithms.user-id-select-match-algorithm.props.column=user_type
+spring.shardingsphere.rules.shadow.shadow-algorithms.user-id-select-match-algorithm.props.value=1
+
+spring.shardingsphere.rules.shadow.shadow-algorithms.simple-hint-algorithm.type=SIMPLE_HINT
+spring.shardingsphere.rules.shadow.shadow-algorithms.simple-hint-algorithm.props.shadow=true
+spring.shardingsphere.rules.shadow.shadow-algorithms.simple-hint-algorithm.props.foo=bar
diff --git a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/pom.xml b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/pom.xml
index c87e35c..8e6be09 100644
--- a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/pom.xml
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/pom.xml
@@ -34,6 +34,9 @@
<module>shardingsphere-jdbc-memory-local-shadow-spring-namespace-jdbc-example</module>
<module>shardingsphere-jdbc-memory-local-shadow-spring-namespace-mybatis-example</module>
<module>shardingsphere-jdbc-memory-local-shadow-spring-namespace-jpa-example</module>
+ <module>shardingsphere-jdbc-memory-local-shadow-spring-boot-starter-jdbc-example</module>
+ <module>shardingsphere-jdbc-memory-local-shadow-spring-boot-starter-jpa-example</module>
+ <module>shardingsphere-jdbc-memory-local-shadow-spring-boot-starter-mybatis-example</module>
</modules>
</project>
diff --git a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-mybatis-example/pom.xml b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local- [...]
similarity index 71%
copy from examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-mybatis-example/pom.xml
copy to examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-boot-starter-jdbc-example/pom.xml
index 3b45368..6dafa73 100644
--- a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-mybatis-example/pom.xml
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-boot-starter-jdbc-example/pom.xml
@@ -25,29 +25,23 @@
<version>${revision}</version>
</parent>
<modelVersion>4.0.0</modelVersion>
- <artifactId>shardingsphere-jdbc-memory-local-shadow-sping-namespace-mybatis-example</artifactId>
+ <artifactId>shardingsphere-jdbc-memory-local-shadow-spring-boot-starter-jdbc-example</artifactId>
<name>${project.artifactId}</name>
<dependencies>
<dependency>
- <groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-jdbc-core-spring-namespace</artifactId>
- </dependency>
- <dependency>
- <groupId>org.mybatis</groupId>
- <artifactId>mybatis</artifactId>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot</artifactId>
+ <version>2.2.0.RELEASE</version>
</dependency>
<dependency>
- <groupId>org.mybatis</groupId>
- <artifactId>mybatis-spring</artifactId>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-autoconfigure</artifactId>
+ <version>2.2.0.RELEASE</version>
</dependency>
<dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-orm</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-context-support</artifactId>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-jdbc-core-spring-boot-starter</artifactId>
</dependency>
</dependencies>
diff --git a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-boot-starter-jdbc-example/src/main/java/org/apache/shardingsphere/example/shadow/spring/boot/starter/jdbc/MemoryLocalShadowSpringBootStarterJdbcExample.java b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example [...]
new file mode 100644
index 0000000..d622527
--- /dev/null
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-boot-starter-jdbc-example/src/main/java/org/apache/shardingsphere/example/shadow/spring/boot/starter/jdbc/MemoryLocalShadowSpringBootStarterJdbcExample.java
@@ -0,0 +1,34 @@
+/*
+ * 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.shadow.spring.boot.starter.jdbc;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.ConfigurableApplicationContext;
+import java.sql.SQLException;
+
+@SpringBootApplication
+public class MemoryLocalShadowSpringBootStarterJdbcExample {
+
+ public static void main(final String[] args) throws SQLException {
+ try (ConfigurableApplicationContext applicationContext = SpringApplication.run(MemoryLocalShadowSpringBootStarterJdbcExample.class, args)) {
+ MemoryLocalShadowSpringBootStarterJdbcExampleService exampleService = applicationContext.getBean(MemoryLocalShadowSpringBootStarterJdbcExampleService.class);
+ exampleService.run();
+ }
+ }
+}
diff --git a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-boot-starter-jdbc-example/src/main/java/org/apache/shardingsphere/example/shadow/spring/boot/starter/jdbc/MemoryLocalShadowSpringBootStarterJdbcExampleService.java b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory- [...]
new file mode 100644
index 0000000..0c48926
--- /dev/null
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-boot-starter-jdbc-example/src/main/java/org/apache/shardingsphere/example/shadow/spring/boot/starter/jdbc/MemoryLocalShadowSpringBootStarterJdbcExampleService.java
@@ -0,0 +1,153 @@
+/*
+ * 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.shadow.spring.boot.starter.jdbc;
+
+import lombok.AllArgsConstructor;
+import org.apache.shardingsphere.example.shadow.spring.boot.starter.jdbc.entity.User;
+import org.springframework.stereotype.Service;
+
+import javax.sql.DataSource;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+
+@Service
+@AllArgsConstructor
+public final class MemoryLocalShadowSpringBootStarterJdbcExampleService {
+
+ private final DataSource dataSource;
+
+ /**
+ * Execute test.
+ *
+ * @throws SQLException
+ */
+ public void run() throws SQLException {
+ try {
+ this.initEnvironment();
+ this.processSuccess();
+ } finally {
+ this.cleanEnvironment();
+ }
+ }
+
+
+ /**
+ * Initialize the database test environment.
+ * @throws SQLException
+ */
+ private void initEnvironment() throws SQLException {
+ String createUserTableSql = "CREATE TABLE IF NOT EXISTS t_user"
+ + "(user_id INT NOT NULL AUTO_INCREMENT, user_name VARCHAR(200), pwd VARCHAR(200), PRIMARY KEY (user_id))";
+ String truncateUserTable = "TRUNCATE TABLE t_user";
+
+ try (Connection connection = dataSource.getConnection();
+ Statement statement = connection.createStatement()) {
+ statement.executeUpdate(createUserTableSql);
+ statement.executeUpdate(truncateUserTable);
+ }
+ }
+
+ private void processSuccess() throws SQLException {
+ System.out.println("-------------- Process Success Begin ---------------");
+ List<Long> ids = insertData();
+ printData();
+ deleteData(ids);
+ printData();
+ System.out.println("-------------- Process Success Finish --------------");
+ }
+
+ private List<Long> insertData() throws SQLException {
+ System.out.println("---------------------------- Insert Data ----------------------------");
+ List<Long> result = new ArrayList<>(10);
+ for (int i = 1; i <= 10; i++) {
+ User user = new User();
+ user.setUserId(i);
+ user.setUserName("test_" + i);
+ user.setPwd("pwd" + i);
+ insert(user);
+ result.add((long) user.getUserId());
+ }
+ return result;
+ }
+
+ private long insert(final User user) throws SQLException {
+ String sql = "INSERT INTO t_user (user_id, user_name, pwd) VALUES (?, ?, ?)";
+ try (Connection connection = dataSource.getConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
+ preparedStatement.setInt(1, user.getUserId());
+ preparedStatement.setString(2, user.getUserName());
+ preparedStatement.setString(3, user.getPwd());
+ preparedStatement.executeUpdate();
+ }
+ return user.getUserId();
+ }
+
+ private void deleteData(final List<Long> orderIds) throws SQLException {
+ System.out.println("---------------------------- Delete Data ----------------------------");
+ String sql = "DELETE FROM t_user WHERE user_id=?";
+ for (Long each : orderIds) {
+ try (Connection connection = dataSource.getConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
+ preparedStatement.setLong(1, each);
+ preparedStatement.executeUpdate();
+ }
+ }
+ }
+
+ private void printData() throws SQLException {
+ System.out.println("---------------------------- Print User Data -----------------------");
+ for (Object each : this.getUsers()) {
+ System.out.println(each);
+ }
+ }
+
+ protected List<User> getUsers() throws SQLException {
+ List<User> result = new LinkedList<>();
+ String sql = "SELECT * FROM t_user";
+ try (Connection connection = dataSource.getConnection();
+ PreparedStatement preparedStatement = connection.prepareStatement(sql);
+ ResultSet resultSet = preparedStatement.executeQuery()) {
+ while (resultSet.next()) {
+ User user = new User();
+ user.setUserId(resultSet.getInt("user_id"));
+ user.setUserName(resultSet.getString("user_name"));
+ user.setPwd(resultSet.getString("pwd"));
+ result.add(user);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Restore the environment.
+ * @throws SQLException
+ */
+ private void cleanEnvironment() throws SQLException {
+ String dropUserSql = "DROP TABLE t_user";
+ try (Connection connection = dataSource.getConnection();
+ Statement statement = connection.createStatement()) {
+ statement.executeUpdate(dropUserSql);
+ }
+ }
+}
diff --git a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-boot-starter-jdbc-example/src/main/java/org/apache/shardingsphere/example/shadow/spring/boot/starter/jdbc/entity/User.java b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local- [...]
new file mode 100644
index 0000000..b884e17
--- /dev/null
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-boot-starter-jdbc-example/src/main/java/org/apache/shardingsphere/example/shadow/spring/boot/starter/jdbc/entity/User.java
@@ -0,0 +1,60 @@
+/*
+ * 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.shadow.spring.boot.starter.jdbc.entity;
+
+import java.io.Serializable;
+
+public class User implements Serializable {
+
+ private static final long serialVersionUID = 263434701950670170L;
+
+ private int userId;
+
+ private String userName;
+
+ private String pwd;
+
+ public int getUserId() {
+ return userId;
+ }
+
+ public void setUserId(final int userId) {
+ this.userId = userId;
+ }
+
+ public String getUserName() {
+ return userName;
+ }
+
+ public void setUserName(final String userName) {
+ this.userName = userName;
+ }
+
+ public String getPwd() {
+ return pwd;
+ }
+
+ public void setPwd(final String pwd) {
+ this.pwd = pwd;
+ }
+
+ @Override
+ public String toString() {
+ return String.format("user_id: %d, user_name: %s, pwd: %s", userId, userName, pwd);
+ }
+}
diff --git a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-boot-starter-jdbc-example/src/main/resources/application.properties b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example [...]
new file mode 100644
index 0000000..8d3c990
--- /dev/null
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-boot-starter-jdbc-example/src/main/resources/application.properties
@@ -0,0 +1,58 @@
+#
+# 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.ds-0.type=com.zaxxer.hikari.HikariDataSource
+spring.shardingsphere.datasource.ds-0.driver-class-name=com.mysql.jdbc.Driver
+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.username=root
+spring.shardingsphere.datasource.ds-0.password=root
+spring.shardingsphere.datasource.ds-0.max-active=16
+
+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.jdbc-url=jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+spring.shardingsphere.datasource.ds-1.username=root
+spring.shardingsphere.datasource.ds-1.password=root
+spring.shardingsphere.datasource.ds-1.max-active=16
+
+spring.shardingsphere.datasource.names=ds-0,ds-1
+
+spring.shardingsphere.rules.shadow.enable=true
+spring.shardingsphere.rules.shadow.data-sources.shadow-data-source.source-data-source-name=ds-0
+spring.shardingsphere.rules.shadow.data-sources.shadow-data-source.shadow-data-source-name=ds-1
+
+spring.shardingsphere.rules.shadow.tables.t_user.data-source-names=shadow-data-source
+spring.shardingsphere.rules.shadow.tables.t_user.shadow-algorithm-names=user-id-insert-match-algorithm,user-id-delete-match-algorithm,user-id-select-match-algorithm,simple-hint-algorithm
+
+spring.shardingsphere.rules.shadow.shadow-algorithms.user-id-insert-match-algorithm.type=VALUE_MATCH
+spring.shardingsphere.rules.shadow.shadow-algorithms.user-id-insert-match-algorithm.props.operation=insert
+spring.shardingsphere.rules.shadow.shadow-algorithms.user-id-insert-match-algorithm.props.column=user_type
+spring.shardingsphere.rules.shadow.shadow-algorithms.user-id-insert-match-algorithm.props.value=1
+
+spring.shardingsphere.rules.shadow.shadow-algorithms.user-id-delete-match-algorithm.type=VALUE_MATCH
+spring.shardingsphere.rules.shadow.shadow-algorithms.user-id-delete-match-algorithm.props.operation=delete
+spring.shardingsphere.rules.shadow.shadow-algorithms.user-id-delete-match-algorithm.props.column=user_type
+spring.shardingsphere.rules.shadow.shadow-algorithms.user-id-delete-match-algorithm.props.value=1
+
+spring.shardingsphere.rules.shadow.shadow-algorithms.user-id-select-match-algorithm.type=VALUE_MATCH
+spring.shardingsphere.rules.shadow.shadow-algorithms.user-id-select-match-algorithm.props.operation=select
+spring.shardingsphere.rules.shadow.shadow-algorithms.user-id-select-match-algorithm.props.column=user_type
+spring.shardingsphere.rules.shadow.shadow-algorithms.user-id-select-match-algorithm.props.value=1
+
+spring.shardingsphere.rules.shadow.shadow-algorithms.simple-hint-algorithm.type=SIMPLE_HINT
+spring.shardingsphere.rules.shadow.shadow-algorithms.simple-hint-algorithm.props.shadow=true
+spring.shardingsphere.rules.shadow.shadow-algorithms.simple-hint-algorithm.props.foo=bar
diff --git a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-boot-starter-jdbc-example/src/main/resources/logback.xml b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsp [...]
new file mode 100644
index 0000000..154abba
--- /dev/null
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-boot-starter-jdbc-example/src/main/resources/logback.xml
@@ -0,0 +1,34 @@
+<?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
+ ~ 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.
+ -->
+
+<configuration>
+ <property name="log.context.name" value="shardingsphere-example" />
+ <property name="log.charset" value="UTF-8" />
+ <property name="log.pattern" value="[%-5level] %date --%thread-- [%logger] %msg %n" />
+ <contextName>${log.context.name}</contextName>
+
+ <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>
diff --git a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-mybatis-example/pom.xml b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local- [...]
similarity index 63%
copy from examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-mybatis-example/pom.xml
copy to examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-boot-starter-jpa-example/pom.xml
index 3b45368..b9cc370 100644
--- a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-mybatis-example/pom.xml
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-boot-starter-jpa-example/pom.xml
@@ -25,29 +25,44 @@
<version>${revision}</version>
</parent>
<modelVersion>4.0.0</modelVersion>
- <artifactId>shardingsphere-jdbc-memory-local-shadow-sping-namespace-mybatis-example</artifactId>
+ <artifactId>shardingsphere-jdbc-memory-local-shadow-spring-boot-starter-jpa-example</artifactId>
<name>${project.artifactId}</name>
-
+
<dependencies>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-jdbc-core-spring-namespace</artifactId>
+ <artifactId>shardingsphere-jdbc-core-spring-boot-starter</artifactId>
</dependency>
<dependency>
- <groupId>org.mybatis</groupId>
- <artifactId>mybatis</artifactId>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-autoconfigure</artifactId>
+ <version>2.2.0.RELEASE</version>
</dependency>
<dependency>
- <groupId>org.mybatis</groupId>
- <artifactId>mybatis-spring</artifactId>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot</artifactId>
+ <version>2.2.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
- <artifactId>spring-orm</artifactId>
+ <artifactId>spring-tx</artifactId>
+ <version>5.2.0.RELEASE</version>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate.javax.persistence</groupId>
+ <artifactId>hibernate-jpa-2.1-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-entitymanager</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
- <artifactId>spring-context-support</artifactId>
+ <artifactId>spring-orm</artifactId>
</dependency>
</dependencies>
diff --git a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-boot-starter-jpa-example/src/main/java/org/apache/shardingsphere/example/shadow/spring/boot/starter/jpa/MemoryLocalShadowSpringBootStarterJpaExample.java b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/sh [...]
new file mode 100644
index 0000000..9b71c76
--- /dev/null
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-boot-starter-jpa-example/src/main/java/org/apache/shardingsphere/example/shadow/spring/boot/starter/jpa/MemoryLocalShadowSpringBootStarterJpaExample.java
@@ -0,0 +1,36 @@
+/*
+ * 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.shadow.spring.boot.starter.jpa;
+
+import org.springframework.boot.autoconfigure.domain.EntityScan;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.ConfigurableApplicationContext;
+import java.sql.SQLException;
+
+@EntityScan(basePackages = "org.apache.shardingsphere.example.shadow.spring.boot.starter.jpa.entity")
+@SpringBootApplication
+public class MemoryLocalShadowSpringBootStarterJpaExample {
+
+ public static void main(final String[] args) throws SQLException {
+ try (ConfigurableApplicationContext applicationContext = SpringApplication.run(MemoryLocalShadowSpringBootStarterJpaExample.class, args)) {
+ MemoryLocalShadowSpringBootStarterJpaExampleService exampleService = applicationContext.getBean(MemoryLocalShadowSpringBootStarterJpaExampleService.class);
+ exampleService.run();
+ }
+ }
+}
diff --git a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-boot-starter-jpa-example/src/main/java/org/apache/shardingsphere/example/shadow/spring/boot/starter/jpa/MemoryLocalShadowSpringBootStarterJpaExampleService.java b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-exa [...]
new file mode 100644
index 0000000..e684b42
--- /dev/null
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-boot-starter-jpa-example/src/main/java/org/apache/shardingsphere/example/shadow/spring/boot/starter/jpa/MemoryLocalShadowSpringBootStarterJpaExampleService.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.example.shadow.spring.boot.starter.jpa;
+
+import org.apache.shardingsphere.example.shadow.spring.boot.starter.jpa.entity.User;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.List;
+
+@Service
+public final class MemoryLocalShadowSpringBootStarterJpaExampleService {
+
+ @Resource
+ private MemoryLocalShadowSpringBootStarterJpaRepository repository;
+
+ /**
+ * Execute test.
+ */
+ public void run() {
+ System.out.println("-------------- Process Success Begin ---------------");
+ List<Integer> usersIds = insertData();
+ printData();
+ deleteData(usersIds);
+ printData();
+ System.out.println("-------------- Process Success Finish --------------");
+ }
+
+ private List<Integer> insertData() {
+ System.out.println("---------------------------- Insert Data ----------------------------");
+ List<Integer> result = new ArrayList<>(10);
+ for (int i = 1; i <= 10; i++) {
+ User user = new User();
+ user.setUserName("test_" + i);
+ user.setPwd("pwd" + i);
+ repository.insertUser(user);
+ result.add(user.getUserId());
+ }
+ return result;
+ }
+
+ private void deleteData(final List<Integer> userIds) {
+ System.out.println("---------------------------- Delete Data ----------------------------");
+ for (Integer each : userIds) {
+ repository.deleteUser(each);
+ }
+ }
+
+ private void printData() {
+ System.out.println("---------------------------- Print User Data -----------------------");
+ for (Object each : repository.selectAllUsers()) {
+ System.out.println(each);
+ }
+ }
+}
diff --git a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-boot-starter-jpa-example/src/main/java/org/apache/shardingsphere/example/shadow/spring/boot/starter/jpa/MemoryLocalShadowSpringBootStarterJpaRepository.java b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example [...]
new file mode 100644
index 0000000..d96f7d7
--- /dev/null
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-boot-starter-jpa-example/src/main/java/org/apache/shardingsphere/example/shadow/spring/boot/starter/jpa/MemoryLocalShadowSpringBootStarterJpaRepository.java
@@ -0,0 +1,50 @@
+/*
+ * 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.shadow.spring.boot.starter.jpa;
+
+import org.apache.shardingsphere.example.shadow.spring.boot.starter.jpa.entity.User;
+import org.springframework.stereotype.Repository;
+
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.Query;
+import javax.transaction.Transactional;
+import java.util.List;
+
+@Repository
+@Transactional
+public class MemoryLocalShadowSpringBootStarterJpaRepository {
+
+ @PersistenceContext
+ private EntityManager entityManager;
+
+ public int insertUser(final User user) {
+ entityManager.persist(user);
+ return user.getUserId();
+ }
+
+ public List<User> selectAllUsers() {
+ return (List<User>) entityManager.createQuery("SELECT o FROM User o").getResultList();
+ }
+
+ public void deleteUser(final int userId) {
+ Query query = entityManager.createQuery("DELETE FROM User o WHERE o.userId = ?1");
+ query.setParameter(1, userId);
+ query.executeUpdate();
+ }
+}
diff --git a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-boot-starter-jpa-example/src/main/java/org/apache/shardingsphere/example/shadow/spring/boot/starter/jpa/entity/User.java b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-ex [...]
new file mode 100644
index 0000000..a1b3d74
--- /dev/null
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-boot-starter-jpa-example/src/main/java/org/apache/shardingsphere/example/shadow/spring/boot/starter/jpa/entity/User.java
@@ -0,0 +1,73 @@
+/*
+ * 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.shadow.spring.boot.starter.jpa.entity;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import java.io.Serializable;
+
+@Entity
+@Table(name = "t_user")
+public class User implements Serializable {
+
+ private static final long serialVersionUID = 263434701950670170L;
+
+ @Id
+ @Column(name = "user_id")
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ private int userId;
+
+ @Column(name = "user_name")
+ private String userName;
+
+ @Column(name = "pwd")
+ private String pwd;
+
+ public int getUserId() {
+ return userId;
+ }
+
+ public void setUserId(final int userId) {
+ this.userId = userId;
+ }
+
+ public String getUserName() {
+ return userName;
+ }
+
+ public void setUserName(final String userName) {
+ this.userName = userName;
+ }
+
+ public String getPwd() {
+ return pwd;
+ }
+
+ public void setPwd(final String pwd) {
+ this.pwd = pwd;
+ }
+
+ @Override
+ public String toString() {
+ return String.format("user_id: %d, user_name: %s, pwd: %s", userId, userName, pwd);
+ }
+}
diff --git a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-boot-starter-jpa-example/src/main/resources/application.properties b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/ [...]
new file mode 100644
index 0000000..99708da
--- /dev/null
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-boot-starter-jpa-example/src/main/resources/application.properties
@@ -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.
+#
+
+spring.jpa.properties.hibernate.hbm2ddl.auto=create-drop
+spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
+spring.jpa.properties.hibernate.show_sql=false
+
+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.jdbc-url=jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+spring.shardingsphere.datasource.ds-0.username=root
+spring.shardingsphere.datasource.ds-0.password=root
+spring.shardingsphere.datasource.ds-0.max-active=16
+
+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.jdbc-url=jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+spring.shardingsphere.datasource.ds-1.username=root
+spring.shardingsphere.datasource.ds-1.password=root
+spring.shardingsphere.datasource.ds-1.max-active=16
+
+spring.shardingsphere.datasource.names=ds-0,ds-1
+
+spring.shardingsphere.rules.shadow.enable=true
+spring.shardingsphere.rules.shadow.data-sources.shadow-data-source.source-data-source-name=ds-0
+spring.shardingsphere.rules.shadow.data-sources.shadow-data-source.shadow-data-source-name=ds-1
+
+spring.shardingsphere.rules.shadow.tables.t_user.data-source-names=shadow-data-source
+spring.shardingsphere.rules.shadow.tables.t_user.shadow-algorithm-names=user-id-insert-match-algorithm,user-id-delete-match-algorithm,user-id-select-match-algorithm,simple-hint-algorithm
+
+spring.shardingsphere.rules.shadow.shadow-algorithms.user-id-insert-match-algorithm.type=VALUE_MATCH
+spring.shardingsphere.rules.shadow.shadow-algorithms.user-id-insert-match-algorithm.props.operation=insert
+spring.shardingsphere.rules.shadow.shadow-algorithms.user-id-insert-match-algorithm.props.column=user_type
+spring.shardingsphere.rules.shadow.shadow-algorithms.user-id-insert-match-algorithm.props.value=1
+
+spring.shardingsphere.rules.shadow.shadow-algorithms.user-id-delete-match-algorithm.type=VALUE_MATCH
+spring.shardingsphere.rules.shadow.shadow-algorithms.user-id-delete-match-algorithm.props.operation=delete
+spring.shardingsphere.rules.shadow.shadow-algorithms.user-id-delete-match-algorithm.props.column=user_type
+spring.shardingsphere.rules.shadow.shadow-algorithms.user-id-delete-match-algorithm.props.value=1
+
+spring.shardingsphere.rules.shadow.shadow-algorithms.user-id-select-match-algorithm.type=VALUE_MATCH
+spring.shardingsphere.rules.shadow.shadow-algorithms.user-id-select-match-algorithm.props.operation=select
+spring.shardingsphere.rules.shadow.shadow-algorithms.user-id-select-match-algorithm.props.column=user_type
+spring.shardingsphere.rules.shadow.shadow-algorithms.user-id-select-match-algorithm.props.value=1
+
+spring.shardingsphere.rules.shadow.shadow-algorithms.simple-hint-algorithm.type=SIMPLE_HINT
+spring.shardingsphere.rules.shadow.shadow-algorithms.simple-hint-algorithm.props.shadow=true
+spring.shardingsphere.rules.shadow.shadow-algorithms.simple-hint-algorithm.props.foo=bar
diff --git a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-boot-starter-jpa-example/src/main/resources/logback.xml b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsph [...]
new file mode 100644
index 0000000..154abba
--- /dev/null
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-boot-starter-jpa-example/src/main/resources/logback.xml
@@ -0,0 +1,34 @@
+<?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
+ ~ 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.
+ -->
+
+<configuration>
+ <property name="log.context.name" value="shardingsphere-example" />
+ <property name="log.charset" value="UTF-8" />
+ <property name="log.pattern" value="[%-5level] %date --%thread-- [%logger] %msg %n" />
+ <contextName>${log.context.name}</contextName>
+
+ <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>
diff --git a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/pom.xml b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-boot-starter-mybatis-example/pom.xml
similarity index 69%
copy from examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/pom.xml
copy to examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-boot-starter-mybatis-example/pom.xml
index c87e35c..cebb062 100644
--- a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/pom.xml
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-boot-starter-mybatis-example/pom.xml
@@ -20,20 +20,23 @@
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">
<parent>
- <artifactId>shardingsphere-jdbc-memory-local-example</artifactId>
+ <artifactId>shardingsphere-jdbc-memory-local-shadow-example</artifactId>
<groupId>org.apache.shardingsphere.example</groupId>
<version>${revision}</version>
</parent>
<modelVersion>4.0.0</modelVersion>
- <packaging>pom</packaging>
- <artifactId>shardingsphere-jdbc-memory-local-shadow-example</artifactId>
+ <artifactId>shardingsphere-jdbc-memory-local-shadow-spring-boot-starter-mybatis-example</artifactId>
<name>${project.artifactId}</name>
-
- <modules>
- <module>shardingsphere-jdbc-memory-local-shadow-jdbc-example</module>
- <module>shardingsphere-jdbc-memory-local-shadow-spring-namespace-jdbc-example</module>
- <module>shardingsphere-jdbc-memory-local-shadow-spring-namespace-mybatis-example</module>
- <module>shardingsphere-jdbc-memory-local-shadow-spring-namespace-jpa-example</module>
- </modules>
+
+ <dependencies>
+ <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>
+ </dependencies>
</project>
diff --git a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-boot-starter-mybatis-example/src/main/java/org/apache/shardingsphere/example/shadow/spring/boot/starter/mybatis/MemoryLocalShadowSpringBootStarterMybatisExample.java b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memor [...]
new file mode 100644
index 0000000..edb641d
--- /dev/null
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-boot-starter-mybatis-example/src/main/java/org/apache/shardingsphere/example/shadow/spring/boot/starter/mybatis/MemoryLocalShadowSpringBootStarterMybatisExample.java
@@ -0,0 +1,36 @@
+/*
+ * 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.shadow.spring.boot.starter.mybatis;
+
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.ConfigurableApplicationContext;
+import java.sql.SQLException;
+
+@MapperScan("org.apache.shardingsphere.example.shadow.spring.boot.starter.mybatis.repository")
+@SpringBootApplication
+public class MemoryLocalShadowSpringBootStarterMybatisExample {
+
+ public static void main(final String[] args) throws SQLException {
+ try (ConfigurableApplicationContext applicationContext = SpringApplication.run(MemoryLocalShadowSpringBootStarterMybatisExample.class, args)) {
+ MemoryLocalShadowSpringBootStarterMybatisExampleService exampleService = applicationContext.getBean(MemoryLocalShadowSpringBootStarterMybatisExampleService.class);
+ exampleService.run();
+ }
+ }
+}
diff --git a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-boot-starter-mybatis-example/src/main/java/org/apache/shardingsphere/example/shadow/spring/boot/starter/mybatis/MemoryLocalShadowSpringBootStarterMybatisExampleService.java b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdb [...]
new file mode 100644
index 0000000..5985a5a
--- /dev/null
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-boot-starter-mybatis-example/src/main/java/org/apache/shardingsphere/example/shadow/spring/boot/starter/mybatis/MemoryLocalShadowSpringBootStarterMybatisExampleService.java
@@ -0,0 +1,103 @@
+/*
+ * 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.shadow.spring.boot.starter.mybatis;
+
+import org.apache.shardingsphere.example.shadow.spring.boot.starter.mybatis.entity.User;
+import org.apache.shardingsphere.example.shadow.spring.boot.starter.mybatis.repository.UserRepository;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+
+@Service
+public final class MemoryLocalShadowSpringBootStarterMybatisExampleService {
+
+ @Resource
+ private UserRepository userRepository;
+
+ /**
+ * Execute test.
+ *
+ * @throws SQLException
+ */
+ public void run() {
+ try {
+ this.initEnvironment();
+ this.processSuccess();
+ } finally {
+ this.cleanEnvironment();
+ }
+ }
+
+ /**
+ * Initialize the database test environment.
+ * @throws SQLException
+ */
+ private void initEnvironment() {
+ userRepository.createTableIfNotExists();
+ userRepository.truncateTable();
+ }
+
+ private void processSuccess() {
+ System.out.println("-------------- Process Success Begin ---------------");
+ List<Long> orderIds = insertData();
+ printData();
+ deleteData(orderIds);
+ printData();
+ System.out.println("-------------- Process Success Finish --------------");
+ }
+
+ private List<Long> insertData() {
+ System.out.println("---------------------------- Insert Data ----------------------------");
+ List<Long> result = new ArrayList<>(10);
+ for (int i = 1; i <= 10; i++) {
+ User user = new User();
+ user.setUserId(i);
+ user.setUserName("test_mybatis_" + i);
+ user.setPwd("pwd_mybatis_" + i);
+ userRepository.insert(user);
+ result.add((long) user.getUserId());
+ }
+ return result;
+ }
+
+ private void deleteData(final List<Long> orderIds) {
+ System.out.println("---------------------------- Delete Data ----------------------------");
+ for (Long each : orderIds) {
+ userRepository.delete(each);
+ }
+ }
+
+ private void printData() {
+ System.out.println("---------------------------- Print Order Data -----------------------");
+ for (Object each : userRepository.selectAll()) {
+ System.out.println(each);
+ }
+ }
+
+ /**
+ * Restore the environment.
+ * @throws SQLException
+ */
+ private void cleanEnvironment() {
+ userRepository.dropTable();
+ }
+
+}
diff --git a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-boot-starter-mybatis-example/src/main/java/org/apache/shardingsphere/example/shadow/spring/boot/starter/mybatis/entity/User.java b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory- [...]
new file mode 100644
index 0000000..993d58e
--- /dev/null
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-boot-starter-mybatis-example/src/main/java/org/apache/shardingsphere/example/shadow/spring/boot/starter/mybatis/entity/User.java
@@ -0,0 +1,60 @@
+/*
+ * 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.shadow.spring.boot.starter.mybatis.entity;
+
+import java.io.Serializable;
+
+public class User implements Serializable {
+
+ private static final long serialVersionUID = 263434701950670170L;
+
+ private int userId;
+
+ private String userName;
+
+ private String pwd;
+
+ public int getUserId() {
+ return userId;
+ }
+
+ public void setUserId(final int userId) {
+ this.userId = userId;
+ }
+
+ public String getUserName() {
+ return userName;
+ }
+
+ public void setUserName(final String userName) {
+ this.userName = userName;
+ }
+
+ public String getPwd() {
+ return pwd;
+ }
+
+ public void setPwd(final String pwd) {
+ this.pwd = pwd;
+ }
+
+ @Override
+ public String toString() {
+ return String.format("user_id: %d, user_name: %s, pwd: %s", userId, userName, pwd);
+ }
+}
diff --git a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-boot-starter-mybatis-example/src/main/java/org/apache/shardingsphere/example/shadow/spring/boot/starter/mybatis/repository/UserRepository.java b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingspher [...]
new file mode 100644
index 0000000..885e384d
--- /dev/null
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-boot-starter-mybatis-example/src/main/java/org/apache/shardingsphere/example/shadow/spring/boot/starter/mybatis/repository/UserRepository.java
@@ -0,0 +1,39 @@
+/*
+ * 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.shadow.spring.boot.starter.mybatis.repository;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.shardingsphere.example.shadow.spring.boot.starter.mybatis.entity.User;
+
+import java.util.List;
+
+@Mapper
+public interface UserRepository {
+
+ void createTableIfNotExists();
+
+ void truncateTable();
+
+ void dropTable();
+
+ void insert(User user);
+
+ void delete(long userId);
+
+ List<User> selectAll();
+}
diff --git a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-boot-starter-mybatis-example/src/main/resources/application.properties b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-exam [...]
new file mode 100644
index 0000000..8253eb7
--- /dev/null
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-boot-starter-mybatis-example/src/main/resources/application.properties
@@ -0,0 +1,60 @@
+#
+# 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.mapper-locations=classpath*:mappers/*Mapper.xml
+
+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.jdbc-url=jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+spring.shardingsphere.datasource.ds-0.username=root
+spring.shardingsphere.datasource.ds-0.password=root
+spring.shardingsphere.datasource.ds-0.max-active=16
+
+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.jdbc-url=jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+spring.shardingsphere.datasource.ds-1.username=root
+spring.shardingsphere.datasource.ds-1.password=root
+spring.shardingsphere.datasource.ds-1.max-active=16
+
+spring.shardingsphere.datasource.names=ds-0,ds-1
+
+spring.shardingsphere.rules.shadow.enable=true
+spring.shardingsphere.rules.shadow.data-sources.shadow-data-source.source-data-source-name=ds-0
+spring.shardingsphere.rules.shadow.data-sources.shadow-data-source.shadow-data-source-name=ds-1
+
+spring.shardingsphere.rules.shadow.tables.t_user.data-source-names=shadow-data-source
+spring.shardingsphere.rules.shadow.tables.t_user.shadow-algorithm-names=user-id-insert-match-algorithm,user-id-delete-match-algorithm,user-id-select-match-algorithm,simple-hint-algorithm
+
+spring.shardingsphere.rules.shadow.shadow-algorithms.user-id-insert-match-algorithm.type=VALUE_MATCH
+spring.shardingsphere.rules.shadow.shadow-algorithms.user-id-insert-match-algorithm.props.operation=insert
+spring.shardingsphere.rules.shadow.shadow-algorithms.user-id-insert-match-algorithm.props.column=user_type
+spring.shardingsphere.rules.shadow.shadow-algorithms.user-id-insert-match-algorithm.props.value=1
+
+spring.shardingsphere.rules.shadow.shadow-algorithms.user-id-delete-match-algorithm.type=VALUE_MATCH
+spring.shardingsphere.rules.shadow.shadow-algorithms.user-id-delete-match-algorithm.props.operation=delete
+spring.shardingsphere.rules.shadow.shadow-algorithms.user-id-delete-match-algorithm.props.column=user_type
+spring.shardingsphere.rules.shadow.shadow-algorithms.user-id-delete-match-algorithm.props.value=1
+
+spring.shardingsphere.rules.shadow.shadow-algorithms.user-id-select-match-algorithm.type=VALUE_MATCH
+spring.shardingsphere.rules.shadow.shadow-algorithms.user-id-select-match-algorithm.props.operation=select
+spring.shardingsphere.rules.shadow.shadow-algorithms.user-id-select-match-algorithm.props.column=user_type
+spring.shardingsphere.rules.shadow.shadow-algorithms.user-id-select-match-algorithm.props.value=1
+
+spring.shardingsphere.rules.shadow.shadow-algorithms.simple-hint-algorithm.type=SIMPLE_HINT
+spring.shardingsphere.rules.shadow.shadow-algorithms.simple-hint-algorithm.props.shadow=true
+spring.shardingsphere.rules.shadow.shadow-algorithms.simple-hint-algorithm.props.foo=bar
diff --git a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-boot-starter-mybatis-example/src/main/resources/logback.xml b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardin [...]
new file mode 100644
index 0000000..154abba
--- /dev/null
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-boot-starter-mybatis-example/src/main/resources/logback.xml
@@ -0,0 +1,34 @@
+<?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
+ ~ 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.
+ -->
+
+<configuration>
+ <property name="log.context.name" value="shardingsphere-example" />
+ <property name="log.charset" value="UTF-8" />
+ <property name="log.pattern" value="[%-5level] %date --%thread-- [%logger] %msg %n" />
+ <contextName>${log.context.name}</contextName>
+
+ <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>
diff --git a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-boot-starter-mybatis-example/src/main/resources/mappers/UserMapper.xml b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-exam [...]
new file mode 100644
index 0000000..dc4d867
--- /dev/null
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-boot-starter-mybatis-example/src/main/resources/mappers/UserMapper.xml
@@ -0,0 +1,51 @@
+<?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
+ ~ 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.
+ -->
+
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.apache.shardingsphere.example.shadow.spring.boot.starter.mybatis.repository.UserRepository">
+ <resultMap id="baseResultMap" type="org.apache.shardingsphere.example.shadow.spring.boot.starter.mybatis.entity.User">
+ <result column="user_id" property="userId" jdbcType="INTEGER"/>
+ <result column="user_name" property="userName" jdbcType="VARCHAR"/>
+ <result column="pwd" property="pwd" jdbcType="VARCHAR"/>
+ <result column="assisted_query_pwd" property="assistedQueryPwd" jdbcType="VARCHAR"/>
+ </resultMap>
+
+ <update id="createTableIfNotExists">
+ CREATE TABLE IF NOT EXISTS t_user (user_id INT NOT NULL AUTO_INCREMENT, user_name VARCHAR(200), pwd VARCHAR(200), PRIMARY KEY (user_id));
+ </update>
+
+ <update id="truncateTable">
+ TRUNCATE TABLE t_user;
+ </update>
+
+ <update id="dropTable">
+ DROP TABLE IF EXISTS t_user;
+ </update>
+
+ <insert id="insert">
+ INSERT INTO t_user (user_id, user_name, pwd) VALUES (#{userId,jdbcType=INTEGER}, #{userName,jdbcType=VARCHAR}, #{pwd,jdbcType=VARCHAR})
+ </insert>
+
+ <delete id="delete">
+ DELETE FROM t_user WHERE user_id = #{userId,jdbcType=INTEGER};
+ </delete>
+
+ <select id="selectAll" resultMap="baseResultMap">
+ SELECT * FROM t_user;
+ </select>
+</mapper>
diff --git a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-mybatis-example/pom.xml b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local- [...]
index 3b45368..ec11165 100644
--- a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-mybatis-example/pom.xml
+++ b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-shadow-example/shardingsphere-jdbc-memory-local-shadow-spring-namespace-mybatis-example/pom.xml
@@ -25,7 +25,7 @@
<version>${revision}</version>
</parent>
<modelVersion>4.0.0</modelVersion>
- <artifactId>shardingsphere-jdbc-memory-local-shadow-sping-namespace-mybatis-example</artifactId>
+ <artifactId>shardingsphere-jdbc-memory-local-shadow-spring-namespace-mybatis-example</artifactId>
<name>${project.artifactId}</name>
<dependencies>