This is an automated email from the ASF dual-hosted git repository.
jianglongtao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new faca53d Migration sharding-readwrite-splitting example (#12969)
faca53d is described below
commit faca53d387106d02873b49805e509fcd95bd8dc4
Author: yx9o <[email protected]>
AuthorDate: Sun Oct 10 09:17:41 2021 +0800
Migration sharding-readwrite-splitting example (#12969)
* Migration sharding-readwrite-splitting example
* Remove the old configuration
---
.../pom.xml | 23 +++++++++++-
...ReadwriteSplittingSpringBootMybatisExample.java | 41 ++++++++++++++++++++++
.../main/resources/META-INF/mybatis-config.xml} | 25 ++++++-------
...ication-sharding-readwrite-splitting.properties | 0
.../src/main/resources/application.properties | 4 ---
.../{pom.xml => src/main/resources/logback.xml} | 29 ++++++++-------
.../src/main/resources/application.properties | 3 +-
7 files changed, 91 insertions(+), 34 deletions(-)
diff --git
a/examples/shardingsphere-jdbc-example/mixed-feature-example/sharding-readwrite-splitting-example/sharding-readwrite-splitting-spring-boot-mybatis-example/pom.xml
b/examples/shardingsphere-jdbc-example/mixed-feature-example/sharding-readwrite-splitting-example/sharding-readwrite-splitting-spring-boot-mybatis-example/pom.xml
index 4cb0406..a9d6d1b 100644
---
a/examples/shardingsphere-jdbc-example/mixed-feature-example/sharding-readwrite-splitting-example/sharding-readwrite-splitting-spring-boot-mybatis-example/pom.xml
+++
b/examples/shardingsphere-jdbc-example/mixed-feature-example/sharding-readwrite-splitting-example/sharding-readwrite-splitting-spring-boot-mybatis-example/pom.xml
@@ -26,6 +26,27 @@
<version>5.0.0-RC1-SNAPSHOT</version>
</parent>
<artifactId>sharding-readwrite-splitting-spring-boot-mybatis-example</artifactId>
- <packaging>pom</packaging>
<name>${project.artifactId}</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.shardingsphere.example</groupId>
+ <artifactId>example-spring-mybatis</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+
<artifactId>shardingsphere-jdbc-core-spring-boot-starter</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.mybatis.spring.boot</groupId>
+ <artifactId>mybatis-spring-boot-starter</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-test</artifactId>
+ </dependency>
+ </dependencies>
</project>
diff --git
a/examples/shardingsphere-jdbc-example/mixed-feature-example/sharding-readwrite-splitting-example/sharding-readwrite-splitting-spring-boot-mybatis-example/src/main/java/org/apache/shardingsphere/example/sharding/readwrite/splitting/spring/boot/mybatis/ShardingReadwriteSplittingSpringBootMybatisExample.java
b/examples/shardingsphere-jdbc-example/mixed-feature-example/sharding-readwrite-splitting-example/sharding-readwrite-splitting-spring-boot-mybatis-example/src/main/java/org/a
[...]
new file mode 100644
index 0000000..5acdc7c
--- /dev/null
+++
b/examples/shardingsphere-jdbc-example/mixed-feature-example/sharding-readwrite-splitting-example/sharding-readwrite-splitting-spring-boot-mybatis-example/src/main/java/org/apache/shardingsphere/example/sharding/readwrite/splitting/spring/boot/mybatis/ShardingReadwriteSplittingSpringBootMybatisExample.java
@@ -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.
+ */
+
+package
org.apache.shardingsphere.example.sharding.readwrite.splitting.spring.boot.mybatis;
+
+import org.apache.shardingsphere.example.core.api.ExampleExecuteTemplate;
+import org.apache.shardingsphere.example.core.api.service.ExampleService;
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import
org.springframework.boot.autoconfigure.transaction.jta.JtaAutoConfiguration;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.context.annotation.ComponentScan;
+
+import java.sql.SQLException;
+
+@ComponentScan("org.apache.shardingsphere.example.core.mybatis")
+@MapperScan(basePackages =
"org.apache.shardingsphere.example.core.mybatis.repository")
+@SpringBootApplication(exclude = JtaAutoConfiguration.class)
+public class ShardingReadwriteSplittingSpringBootMybatisExample {
+
+ public static void main(final String[] args) throws SQLException {
+ try (ConfigurableApplicationContext applicationContext =
SpringApplication.run(ShardingReadwriteSplittingSpringBootMybatisExample.class,
args)) {
+
ExampleExecuteTemplate.run(applicationContext.getBean(ExampleService.class));
+ }
+ }
+}
diff --git
a/examples/shardingsphere-jdbc-example/mixed-feature-example/sharding-readwrite-splitting-example/sharding-readwrite-splitting-spring-boot-mybatis-example/pom.xml
b/examples/shardingsphere-jdbc-example/mixed-feature-example/sharding-readwrite-splitting-example/sharding-readwrite-splitting-spring-boot-mybatis-example/src/main/resources/META-INF/mybatis-config.xml
similarity index 54%
copy from
examples/shardingsphere-jdbc-example/mixed-feature-example/sharding-readwrite-splitting-example/sharding-readwrite-splitting-spring-boot-mybatis-example/pom.xml
copy to
examples/shardingsphere-jdbc-example/mixed-feature-example/sharding-readwrite-splitting-example/sharding-readwrite-splitting-spring-boot-mybatis-example/src/main/resources/META-INF/mybatis-config.xml
index 4cb0406..84a6692 100644
---
a/examples/shardingsphere-jdbc-example/mixed-feature-example/sharding-readwrite-splitting-example/sharding-readwrite-splitting-spring-boot-mybatis-example/pom.xml
+++
b/examples/shardingsphere-jdbc-example/mixed-feature-example/sharding-readwrite-splitting-example/sharding-readwrite-splitting-spring-boot-mybatis-example/src/main/resources/META-INF/mybatis-config.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?>
+<?xml version="1.0" encoding="UTF-8" ?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one or more
~ contributor license agreements. See the NOTICE file distributed with
@@ -16,16 +16,13 @@
~ limitations under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.shardingsphere.example</groupId>
- <artifactId>sharding-readwrite-splitting-example</artifactId>
- <version>5.0.0-RC1-SNAPSHOT</version>
- </parent>
-
<artifactId>sharding-readwrite-splitting-spring-boot-mybatis-example</artifactId>
- <packaging>pom</packaging>
- <name>${project.artifactId}</name>
-</project>
+<!DOCTYPE configuration
+ PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
+ "http://mybatis.org/dtd/mybatis-3-config.dtd">
+<configuration>
+ <mappers>
+ <mapper resource="META-INF/mappers/AddressMapper.xml"/>
+ <mapper resource="META-INF/mappers/OrderMapper.xml"/>
+ <mapper resource="META-INF/mappers/OrderItemMapper.xml"/>
+ </mappers>
+</configuration>
diff --git
a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-readwrite-splitting.properties
b/examples/shardingsphere-jdbc-example/mixed-feature-example/sharding-readwrite-splitting-example/sharding-readwrite-splitting-spring-boot-mybatis-example/src/main/resources/application-sharding-readwrite-splitting.properties
similarity index 100%
rename from
examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/application-sharding-readwrite-splitting.properties
rename to
examples/shardingsphere-jdbc-example/mixed-feature-example/sharding-readwrite-splitting-example/sharding-readwrite-splitting-spring-boot-mybatis-example/src/main/resources/application-sharding-readwrite-splitting.properties
diff --git
a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/application.properties
b/examples/shardingsphere-jdbc-example/mixed-feature-example/sharding-readwrite-splitting-example/sharding-readwrite-splitting-spring-boot-mybatis-example/src/main/resources/application.properties
similarity index 83%
copy from
examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/application.properties
copy to
examples/shardingsphere-jdbc-example/mixed-feature-example/sharding-readwrite-splitting-example/sharding-readwrite-splitting-spring-boot-mybatis-example/src/main/resources/application.properties
index c2f1529..3d05eec 100644
---
a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/application.properties
+++
b/examples/shardingsphere-jdbc-example/mixed-feature-example/sharding-readwrite-splitting-example/sharding-readwrite-splitting-spring-boot-mybatis-example/src/main/resources/application.properties
@@ -17,8 +17,4 @@
mybatis.config-location=classpath:META-INF/mybatis-config.xml
-#spring.profiles.active=sharding-databases
-#spring.profiles.active=sharding-tables
-#spring.profiles.active=sharding-databases-tables
-#spring.profiles.active=readwrite-splitting
spring.profiles.active=sharding-readwrite-splitting
diff --git
a/examples/shardingsphere-jdbc-example/mixed-feature-example/sharding-readwrite-splitting-example/sharding-readwrite-splitting-spring-boot-mybatis-example/pom.xml
b/examples/shardingsphere-jdbc-example/mixed-feature-example/sharding-readwrite-splitting-example/sharding-readwrite-splitting-spring-boot-mybatis-example/src/main/resources/logback.xml
similarity index 57%
copy from
examples/shardingsphere-jdbc-example/mixed-feature-example/sharding-readwrite-splitting-example/sharding-readwrite-splitting-spring-boot-mybatis-example/pom.xml
copy to
examples/shardingsphere-jdbc-example/mixed-feature-example/sharding-readwrite-splitting-example/sharding-readwrite-splitting-spring-boot-mybatis-example/src/main/resources/logback.xml
index 4cb0406..dafd6e9 100644
---
a/examples/shardingsphere-jdbc-example/mixed-feature-example/sharding-readwrite-splitting-example/sharding-readwrite-splitting-spring-boot-mybatis-example/pom.xml
+++
b/examples/shardingsphere-jdbc-example/mixed-feature-example/sharding-readwrite-splitting-example/sharding-readwrite-splitting-spring-boot-mybatis-example/src/main/resources/logback.xml
@@ -16,16 +16,19 @@
~ limitations under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.shardingsphere.example</groupId>
- <artifactId>sharding-readwrite-splitting-example</artifactId>
- <version>5.0.0-RC1-SNAPSHOT</version>
- </parent>
-
<artifactId>sharding-readwrite-splitting-spring-boot-mybatis-example</artifactId>
- <packaging>pom</packaging>
- <name>${project.artifactId}</name>
-</project>
+<configuration>
+ <property name="log.context.name"
value="sharding-readwrite-splitting-spring-boot-mybatis-example" />
+ <property name="log.charset" value="UTF-8" />
+ <property name="log.pattern" value="[%-5level] %date --%thread-- [%logger]
%msg %n" />
+ <contextName>${log.context.name}</contextName>
+
+ <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-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/application.properties
b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/application.properties
index c2f1529..7ca885f 100644
---
a/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/application.properties
+++
b/examples/shardingsphere-jdbc-example/single-feature-example/sharding-example/sharding-spring-boot-mybatis-example/src/main/resources/application.properties
@@ -17,8 +17,7 @@
mybatis.config-location=classpath:META-INF/mybatis-config.xml
-#spring.profiles.active=sharding-databases
+spring.profiles.active=sharding-databases
#spring.profiles.active=sharding-tables
#spring.profiles.active=sharding-databases-tables
#spring.profiles.active=readwrite-splitting
-spring.profiles.active=sharding-readwrite-splitting