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 9313210  Add db-discovery spring boot starter example (#14312)
9313210 is described below

commit 93132106cb44f267dd4f59eabd7ef7faaf1cc28d
Author: Guocheng Tang <[email protected]>
AuthorDate: Sat Dec 25 16:38:23 2021 +0800

    Add db-discovery spring boot starter example (#14312)
    
    * Add spring boot starter jpa example
    
    * Add spring boot starter mybatis example
---
 .../pom.xml                                        |   3 +
 .../pom.xml                                        |  69 +++++++++++
 ...ocalDbDiscoverySpringBootStarterJpaExample.java |  36 ++++++
 ...iscoverySpringBootStarterJpaExampleService.java |  83 +++++++++++++
 ...lDbDiscoverySpringBootStarterJpaRepository.java |  66 +++++++++++
 .../spring/boot/starter/jpa/entity/Order.java      |  84 +++++++++++++
 .../spring/boot/starter/jpa/entity/OrderItem.java  |  84 +++++++++++++
 .../src/main/resources/application.properties      |  54 +++++++++
 .../src/main/resources/logback.xml}                |  32 +++--
 .../pom.xml                                        |  18 ++-
 ...DbDiscoverySpringBootStarterMybatisExample.java |  36 ++++++
 ...verySpringBootStarterMybatisExampleService.java | 130 +++++++++++++++++++++
 .../spring/boot/starter/mybatis/entity/Order.java  |  70 +++++++++++
 .../boot/starter/mybatis/entity/OrderItem.java     |  70 +++++++++++
 .../mybatis/repository/OrderItemRepository.java    |  39 +++++++
 .../mybatis/repository/OrderRepository.java        |  39 +++++++
 .../src/main/resources/application.properties      |  52 +++++++++
 .../src/main/resources/logback.xml}                |  32 +++--
 .../src/main/resources/mappers/OrderItemMapper.xml |  51 ++++++++
 .../src/main/resources/mappers/OrderMapper.xml     |  51 ++++++++
 20 files changed, 1059 insertions(+), 40 deletions(-)

diff --git 
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-db-discovery-example/pom.xml
 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-db-discovery-example/pom.xml
index 68f1cde..8af3fdf 100644
--- 
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-db-discovery-example/pom.xml
+++ 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-db-discovery-example/pom.xml
@@ -31,6 +31,9 @@
     
     <modules>
         
<module>shardingsphere-jdbc-memory-local-db-discovery-jdbc-example</module>
+        
<module>shardingsphere-jdbc-memory-local-db-discovery-spring-boot-starter-jdbc-example</module>
+        
<module>shardingsphere-jdbc-memory-local-db-discovery-spring-boot-starter-jpa-example</module>
+        
<module>shardingsphere-jdbc-memory-local-db-discovery-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-db-discovery-example/shardingsphere-jdbc-memory-local-db-discovery-spring-boot-starter-jpa-example/pom.xml
 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-db-discovery-example/shardingsphere-j
 [...]
new file mode 100644
index 0000000..aafa1fe
--- /dev/null
+++ 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-db-discovery-example/shardingsphere-jdbc-memory-local-db-discovery-spring-boot-starter-jpa-example/pom.xml
@@ -0,0 +1,69 @@
+<?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.
+  -->
+
+<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";>
+    <parent>
+        
<artifactId>shardingsphere-jdbc-memory-local-db-discovery-example</artifactId>
+        <groupId>org.apache.shardingsphere.example</groupId>
+        <version>${revision}</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+    
<artifactId>shardingsphere-jdbc-memory-local-db-discovery-spring-boot-starter-jpa-example</artifactId>
+    <name>${project.artifactId}</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.shardingsphere</groupId>
+            
<artifactId>shardingsphere-jdbc-core-spring-boot-starter</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-autoconfigure</artifactId>
+            <version>2.2.0.RELEASE</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot</artifactId>
+            <version>2.2.0.RELEASE</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <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-orm</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-db-discovery-example/shardingsphere-jdbc-memory-local-db-discovery-spring-boot-starter-jpa-example/src/main/java/org/apache/shardingsphere/example/db/discovery/spring/boot/starter/jpa/MemoryLocalDbDiscoverySpringBootStarterJpaExample.java
 b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere 
[...]
new file mode 100644
index 0000000..2a0c102
--- /dev/null
+++ 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-db-discovery-example/shardingsphere-jdbc-memory-local-db-discovery-spring-boot-starter-jpa-example/src/main/java/org/apache/shardingsphere/example/db/discovery/spring/boot/starter/jpa/MemoryLocalDbDiscoverySpringBootStarterJpaExample.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.db.discovery.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.db.discovery.spring.boot.starter.jpa.entity")
+@SpringBootApplication
+public class MemoryLocalDbDiscoverySpringBootStarterJpaExample {
+    
+    public static void main(final String[] args) throws SQLException {
+        try (ConfigurableApplicationContext applicationContext = 
SpringApplication.run(MemoryLocalDbDiscoverySpringBootStarterJpaExample.class, 
args)) {
+            MemoryLocalDbDiscoverySpringBootStarterJpaExampleService 
exampleService = 
applicationContext.getBean(MemoryLocalDbDiscoverySpringBootStarterJpaExampleService.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-db-discovery-example/shardingsphere-jdbc-memory-local-db-discovery-spring-boot-starter-jpa-example/src/main/java/org/apache/shardingsphere/example/db/discovery/spring/boot/starter/jpa/MemoryLocalDbDiscoverySpringBootStarterJpaExampleService.java
 b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardin [...]
new file mode 100644
index 0000000..ec09c1a
--- /dev/null
+++ 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-db-discovery-example/shardingsphere-jdbc-memory-local-db-discovery-spring-boot-starter-jpa-example/src/main/java/org/apache/shardingsphere/example/db/discovery/spring/boot/starter/jpa/MemoryLocalDbDiscoverySpringBootStarterJpaExampleService.java
@@ -0,0 +1,83 @@
+/*
+ * 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.db.discovery.spring.boot.starter.jpa;
+
+import 
org.apache.shardingsphere.example.db.discovery.spring.boot.starter.jpa.entity.Order;
+import 
org.apache.shardingsphere.example.db.discovery.spring.boot.starter.jpa.entity.OrderItem;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.List;
+
+@Service
+public final class MemoryLocalDbDiscoverySpringBootStarterJpaExampleService {
+    
+    @Resource
+    private MemoryLocalDbDiscoverySpringBootStarterJpaRepository repository;
+
+    /**
+     * Execute test.
+     */
+    public void run() {
+        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++) {
+            Order order = new Order();
+            order.setUserId(i);
+            order.setAddressId(i);
+            order.setStatus("INSERT_TEST");
+            repository.insertOrder(order);
+            OrderItem orderItem = new OrderItem();
+            orderItem.setOrderId(order.getOrderId());
+            orderItem.setUserId(i);
+            orderItem.setStatus("INSERT_TEST");
+            repository.insertOrderItem(orderItem);
+            result.add(order.getOrderId());
+        }
+        return result;
+    }
+
+    private void deleteData(final List<Long> orderIds) {
+        System.out.println("---------------------------- Delete Data 
----------------------------");
+        for (Long each : orderIds) {
+            repository.deleteOrder(each);
+            repository.deleteOrderItem(each);
+        }
+    }
+    
+    private void printData() {
+        System.out.println("---------------------------- Print Order Data 
-----------------------");
+        for (Object each : repository.selectAllOrder()) {
+            System.out.println(each);
+        }
+        System.out.println("---------------------------- Print OrderItem Data 
-------------------");
+        for (Object each : repository.selectAllOrderItem()) {
+            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-db-discovery-example/shardingsphere-jdbc-memory-local-db-discovery-spring-boot-starter-jpa-example/src/main/java/org/apache/shardingsphere/example/db/discovery/spring/boot/starter/jpa/MemoryLocalDbDiscoverySpringBootStarterJpaRepository.java
 b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsph [...]
new file mode 100644
index 0000000..5816550
--- /dev/null
+++ 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-db-discovery-example/shardingsphere-jdbc-memory-local-db-discovery-spring-boot-starter-jpa-example/src/main/java/org/apache/shardingsphere/example/db/discovery/spring/boot/starter/jpa/MemoryLocalDbDiscoverySpringBootStarterJpaRepository.java
@@ -0,0 +1,66 @@
+/*
+ * 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.db.discovery.spring.boot.starter.jpa;
+
+import 
org.apache.shardingsphere.example.db.discovery.spring.boot.starter.jpa.entity.Order;
+import 
org.apache.shardingsphere.example.db.discovery.spring.boot.starter.jpa.entity.OrderItem;
+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 MemoryLocalDbDiscoverySpringBootStarterJpaRepository {
+    
+    @PersistenceContext
+    private EntityManager entityManager;
+
+    public Long insertOrder(final Order order) {
+        entityManager.persist(order);
+        return order.getOrderId();
+    }
+
+    public Long insertOrderItem(final OrderItem orderItem) {
+        entityManager.persist(orderItem);
+        return orderItem.getOrderItemId();
+    }
+    
+    public List<Order> selectAllOrder() {
+        return (List<Order>) entityManager.createQuery("SELECT o FROM Order 
o").getResultList();
+    }
+    
+    public List<OrderItem> selectAllOrderItem() {
+        return (List<OrderItem>) entityManager.createQuery("SELECT o from 
OrderItem o").getResultList();
+    }
+
+    public void deleteOrder(final Long orderId) {
+        Query query = entityManager.createQuery("DELETE FROM Order o WHERE 
o.orderId = ?1");
+        query.setParameter(1, orderId);
+        query.executeUpdate();
+    }
+
+    public void deleteOrderItem(final Long orderId) {
+        Query query = entityManager.createQuery("DELETE FROM OrderItem i WHERE 
i.orderId = ?1");
+        query.setParameter(1, orderId);
+        query.executeUpdate();
+    }
+}
diff --git 
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-db-discovery-example/shardingsphere-jdbc-memory-local-db-discovery-spring-boot-starter-jpa-example/src/main/java/org/apache/shardingsphere/example/db/discovery/spring/boot/starter/jpa/entity/Order.java
 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-j
 [...]
new file mode 100644
index 0000000..56b8309
--- /dev/null
+++ 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-db-discovery-example/shardingsphere-jdbc-memory-local-db-discovery-spring-boot-starter-jpa-example/src/main/java/org/apache/shardingsphere/example/db/discovery/spring/boot/starter/jpa/entity/Order.java
@@ -0,0 +1,84 @@
+/*
+ * 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.db.discovery.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_order")
+public class Order implements Serializable {
+    
+    private static final long serialVersionUID = 8306802022239174861L;
+    
+    @Id
+    @Column(name = "order_id")
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    private long orderId;
+    
+    @Column(name = "user_id")
+    private int userId;
+    
+    @Column(name = "address_id")
+    private long addressId;
+    
+    @Column(name = "status")
+    private String status;
+    
+    public long getOrderId() {
+        return orderId;
+    }
+    
+    public void setOrderId(final long orderId) {
+        this.orderId = orderId;
+    }
+    
+    public int getUserId() {
+        return userId;
+    }
+    
+    public void setUserId(final int userId) {
+        this.userId = userId;
+    }
+    
+    public String getStatus() {
+        return status;
+    }
+    
+    public void setStatus(final String status) {
+        this.status = status;
+    }
+    
+    public long getAddressId() {
+        return addressId;
+    }
+    
+    public void setAddressId(final long addressId) {
+        this.addressId = addressId;
+    }
+    
+    @Override
+    public String toString() {
+        return String.format("order_id: %s, user_id: %s, address_id: %s, 
status: %s", orderId, userId, addressId, status);
+    }
+}
diff --git 
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-db-discovery-example/shardingsphere-jdbc-memory-local-db-discovery-spring-boot-starter-jpa-example/src/main/java/org/apache/shardingsphere/example/db/discovery/spring/boot/starter/jpa/entity/OrderItem.java
 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphe
 [...]
new file mode 100644
index 0000000..63c9314
--- /dev/null
+++ 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-db-discovery-example/shardingsphere-jdbc-memory-local-db-discovery-spring-boot-starter-jpa-example/src/main/java/org/apache/shardingsphere/example/db/discovery/spring/boot/starter/jpa/entity/OrderItem.java
@@ -0,0 +1,84 @@
+/*
+ * 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.db.discovery.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_order_item")
+public class OrderItem implements Serializable {
+    
+    private static final long serialVersionUID = 1332162822494069342L;
+    
+    @Id
+    @Column(name = "order_item_id")
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    private long orderItemId;
+    
+    @Column(name = "order_id")
+    private long orderId;
+    
+    @Column(name = "user_id")
+    private int userId;
+    
+    @Column(name = "status")
+    private String status;
+    
+    public long getOrderItemId() {
+        return orderItemId;
+    }
+    
+    public void setOrderItemId(final long orderItemId) {
+        this.orderItemId = orderItemId;
+    }
+    
+    public long getOrderId() {
+        return orderId;
+    }
+    
+    public void setOrderId(final long orderId) {
+        this.orderId = orderId;
+    }
+    
+    public int getUserId() {
+        return userId;
+    }
+    
+    public void setUserId(final int userId) {
+        this.userId = userId;
+    }
+    
+    public String getStatus() {
+        return status;
+    }
+    
+    public void setStatus(final String status) {
+        this.status = status;
+    }
+    
+    @Override
+    public String toString() {
+        return String.format("order_item_id:%s, order_id: %s, user_id: %s, 
status: %s", orderItemId, orderId, userId, status);
+    }
+}
diff --git 
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-db-discovery-example/shardingsphere-jdbc-memory-local-db-discovery-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-db-
 [...]
new file mode 100644
index 0000000..81a0f39
--- /dev/null
+++ 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-db-discovery-example/shardingsphere-jdbc-memory-local-db-discovery-spring-boot-starter-jpa-example/src/main/resources/application.properties
@@ -0,0 +1,54 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+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.names=ds-0,ds-0-replica-0,ds-0-replica-1
+
+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://172.72.0.15:3306/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-0-replica-0.type=com.zaxxer.hikari.HikariDataSource
+spring.shardingsphere.datasource.ds-0-replica-0.driver-class-name=com.mysql.jdbc.Driver
+spring.shardingsphere.datasource.ds-0-replica-0.jdbc-url=jdbc:mysql://172.72.0.16:3306/ds_0_replica_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+spring.shardingsphere.datasource.ds-0-replica-0.username=root
+spring.shardingsphere.datasource.ds-0-replica-0.password=root
+spring.shardingsphere.datasource.ds-0-replica-0.max-active=16
+
+spring.shardingsphere.datasource.ds-0-replica-1.type=com.zaxxer.hikari.HikariDataSource
+spring.shardingsphere.datasource.ds-0-replica-1.driver-class-name=com.mysql.jdbc.Driver
+spring.shardingsphere.datasource.ds-0-replica-1.jdbc-url=jdbc:mysql://172.72.0.17:3306/ds_0_replica_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+spring.shardingsphere.datasource.ds-0-replica-1.username=root
+spring.shardingsphere.datasource.ds-0-replica-1.password=root
+spring.shardingsphere.datasource.ds-0-replica-1.max-active=16
+
+spring.shardingsphere.rules.database-discovery.data-sources.rule.data-source-names=ds-0,ds-0-replica-0,ds-0-replica-1
+spring.shardingsphere.rules.database-discovery.data-sources.rule.discovery-heartbeat-name=mgr-heartbeat
+spring.shardingsphere.rules.database-discovery.data-sources.rule.discovery-type-name=mgr
+spring.shardingsphere.rules.database-discovery.discovery-heartbeats.mgr-heartbeat.props.keep-alive-cron=0/5
 * * * * ?
+spring.shardingsphere.rules.database-discovery.discovery-types.mgr.type=MGR
+spring.shardingsphere.rules.database-discovery.discovery-types.mgr.props.keep-alive-cron=0/5
 * * * * ?
+spring.shardingsphere.rules.database-discovery.discovery-types.mgr.props.group-name=aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa
+
+
+
diff --git 
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-db-discovery-example/pom.xml
 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-db-discovery-example/shardingsphere-jdbc-memory-local-db-discovery-spring-boot-starter-jpa-example/src/main/resourc
 [...]
similarity index 53%
copy from 
examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-db-discovery-example/pom.xml
copy to 
examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-db-discovery-example/shardingsphere-jdbc-memory-local-db-discovery-spring-boot-starter-jpa-example/src/main/resources/logback.xml
index 68f1cde..154abba 100644
--- 
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-db-discovery-example/pom.xml
+++ 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-db-discovery-example/shardingsphere-jdbc-memory-local-db-discovery-spring-boot-starter-jpa-example/src/main/resources/logback.xml
@@ -16,21 +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";>
-    <parent>
-        <artifactId>shardingsphere-jdbc-memory-local-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-db-discovery-example</artifactId>
-    <name>${project.artifactId}</name>
+<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>
     
-    <modules>
-        
<module>shardingsphere-jdbc-memory-local-db-discovery-jdbc-example</module>
-    </modules>
-    
-</project>
+    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder charset="${log.charset}">
+            <pattern>${log.pattern}</pattern>
+        </encoder>
+    </appender>
+    <root>
+        <level value="INFO" />
+        <appender-ref ref="STDOUT" />
+    </root>
+</configuration>
diff --git 
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-db-discovery-example/pom.xml
 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-db-discovery-example/shardingsphere-jdbc-memory-local-db-discovery-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-db-discovery-example/pom.xml
copy to 
examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-db-discovery-example/shardingsphere-jdbc-memory-local-db-discovery-spring-boot-starter-mybatis-example/pom.xml
index 68f1cde..98768b6 100644
--- 
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-db-discovery-example/pom.xml
+++ 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-db-discovery-example/shardingsphere-jdbc-memory-local-db-discovery-spring-boot-starter-mybatis-example/pom.xml
@@ -20,17 +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-db-discovery-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-db-discovery-example</artifactId>
+    
<artifactId>shardingsphere-jdbc-memory-local-db-discovery-spring-boot-starter-mybatis-example</artifactId>
     <name>${project.artifactId}</name>
     
-    <modules>
-        
<module>shardingsphere-jdbc-memory-local-db-discovery-jdbc-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-db-discovery-example/shardingsphere-jdbc-memory-local-db-discovery-spring-boot-starter-mybatis-example/src/main/java/org/apache/shardingsphere/example/db/discovery/spring/boot/starter/mybatis/MemoryLocalDbDiscoverySpringBootStarterMybatisExample.java
 b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/sh [...]
new file mode 100644
index 0000000..750e129
--- /dev/null
+++ 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-db-discovery-example/shardingsphere-jdbc-memory-local-db-discovery-spring-boot-starter-mybatis-example/src/main/java/org/apache/shardingsphere/example/db/discovery/spring/boot/starter/mybatis/MemoryLocalDbDiscoverySpringBootStarterMybatisExample.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.db.discovery.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.db.discovery.spring.boot.starter.mybatis.repository")
+@SpringBootApplication
+public class MemoryLocalDbDiscoverySpringBootStarterMybatisExample {
+    
+    public static void main(final String[] args) throws SQLException {
+        try (ConfigurableApplicationContext applicationContext = 
SpringApplication.run(MemoryLocalDbDiscoverySpringBootStarterMybatisExample.class,
 args)) {
+            MemoryLocalDbDiscoverySpringBootStarterMybatisExampleService 
exampleService = 
applicationContext.getBean(MemoryLocalDbDiscoverySpringBootStarterMybatisExampleService.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-db-discovery-example/shardingsphere-jdbc-memory-local-db-discovery-spring-boot-starter-mybatis-example/src/main/java/org/apache/shardingsphere/example/db/discovery/spring/boot/starter/mybatis/MemoryLocalDbDiscoverySpringBootStarterMybatisExampleService.java
 b/examples/shardingsphere-sample/shardingsphere-jdbc-sa [...]
new file mode 100644
index 0000000..b1f330b
--- /dev/null
+++ 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-db-discovery-example/shardingsphere-jdbc-memory-local-db-discovery-spring-boot-starter-mybatis-example/src/main/java/org/apache/shardingsphere/example/db/discovery/spring/boot/starter/mybatis/MemoryLocalDbDiscoverySpringBootStarterMybatisExampleService.java
@@ -0,0 +1,130 @@
+/*
+ * 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.db.discovery.spring.boot.starter.mybatis;
+
+import 
org.apache.shardingsphere.example.db.discovery.spring.boot.starter.mybatis.entity.Order;
+import 
org.apache.shardingsphere.example.db.discovery.spring.boot.starter.mybatis.entity.OrderItem;
+import 
org.apache.shardingsphere.example.db.discovery.spring.boot.starter.mybatis.repository.OrderItemRepository;
+import 
org.apache.shardingsphere.example.db.discovery.spring.boot.starter.mybatis.repository.OrderRepository;
+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 
MemoryLocalDbDiscoverySpringBootStarterMybatisExampleService {
+
+    @Resource
+    private OrderRepository orderRepository;
+    
+    @Resource
+    private OrderItemRepository orderItemRepository;
+
+    /**
+     * 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() {
+        orderRepository.createTableIfNotExists();
+        orderItemRepository.createTableIfNotExists();
+        orderRepository.truncateTable();
+        orderItemRepository.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++) {
+            Order order = insertOrder(i);
+            insertOrderItem(i, order);
+            result.add(order.getOrderId());
+        }
+        return result;
+    }
+    
+    private Order insertOrder(final int i) {
+        Order order = new Order();
+        order.setUserId(i);
+        order.setAddressId(i);
+        order.setStatus("INSERT_TEST");
+        orderRepository.insert(order);
+        return order;
+    }
+
+    private void insertOrderItem(final int i, final Order order) {
+        OrderItem orderItem = new OrderItem();
+        orderItem.setOrderId(order.getOrderId());
+        orderItem.setUserId(i);
+        orderItem.setStatus("INSERT_TEST");
+        orderItemRepository.insert(orderItem);
+    }
+
+    private void deleteData(final List<Long> orderIds) {
+        System.out.println("---------------------------- Delete Data 
----------------------------");
+        for (Long each : orderIds) {
+            orderRepository.delete(each);
+            orderItemRepository.delete(each);
+        }
+    }
+    
+    private void printData() {
+        System.out.println("---------------------------- Print Order Data 
-----------------------");
+        for (Object each : orderRepository.selectAll()) {
+            System.out.println(each);
+        }
+        System.out.println("---------------------------- Print OrderItem Data 
-------------------");
+        for (Object each : orderItemRepository.selectAll()) {
+            System.out.println(each);
+        }
+    }
+    
+    /**
+     * Restore the environment.
+     * @throws SQLException
+     */
+    private void cleanEnvironment() {
+        orderRepository.dropTable();
+        orderItemRepository.dropTable();
+    }
+
+}
diff --git 
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-db-discovery-example/shardingsphere-jdbc-memory-local-db-discovery-spring-boot-starter-mybatis-example/src/main/java/org/apache/shardingsphere/example/db/discovery/spring/boot/starter/mybatis/entity/Order.java
 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/sharding
 [...]
new file mode 100644
index 0000000..8f85244
--- /dev/null
+++ 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-db-discovery-example/shardingsphere-jdbc-memory-local-db-discovery-spring-boot-starter-mybatis-example/src/main/java/org/apache/shardingsphere/example/db/discovery/spring/boot/starter/mybatis/entity/Order.java
@@ -0,0 +1,70 @@
+/*
+ * 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.db.discovery.spring.boot.starter.mybatis.entity;
+
+import java.io.Serializable;
+
+public class Order implements Serializable {
+    
+    private static final long serialVersionUID = 8306802022239174861L;
+    
+    private long orderId;
+    
+    private int userId;
+    
+    private long addressId;
+    
+    private String status;
+    
+    public long getOrderId() {
+        return orderId;
+    }
+    
+    public void setOrderId(final long orderId) {
+        this.orderId = orderId;
+    }
+    
+    public int getUserId() {
+        return userId;
+    }
+    
+    public void setUserId(final int userId) {
+        this.userId = userId;
+    }
+    
+    public String getStatus() {
+        return status;
+    }
+    
+    public void setStatus(final String status) {
+        this.status = status;
+    }
+    
+    public long getAddressId() {
+        return addressId;
+    }
+    
+    public void setAddressId(final long addressId) {
+        this.addressId = addressId;
+    }
+    
+    @Override
+    public String toString() {
+        return String.format("order_id: %s, user_id: %s, address_id: %s, 
status: %s", orderId, userId, addressId, status);
+    }
+}
diff --git 
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-db-discovery-example/shardingsphere-jdbc-memory-local-db-discovery-spring-boot-starter-mybatis-example/src/main/java/org/apache/shardingsphere/example/db/discovery/spring/boot/starter/mybatis/entity/OrderItem.java
 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shar
 [...]
new file mode 100644
index 0000000..97a350a
--- /dev/null
+++ 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-db-discovery-example/shardingsphere-jdbc-memory-local-db-discovery-spring-boot-starter-mybatis-example/src/main/java/org/apache/shardingsphere/example/db/discovery/spring/boot/starter/mybatis/entity/OrderItem.java
@@ -0,0 +1,70 @@
+/*
+ * 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.db.discovery.spring.boot.starter.mybatis.entity;
+
+import java.io.Serializable;
+
+public class OrderItem implements Serializable {
+    
+    private static final long serialVersionUID = 1332162822494069342L;
+    
+    private long orderItemId;
+    
+    private long orderId;
+    
+    private int userId;
+    
+    private String status;
+    
+    public long getOrderItemId() {
+        return orderItemId;
+    }
+    
+    public void setOrderItemId(final long orderItemId) {
+        this.orderItemId = orderItemId;
+    }
+    
+    public long getOrderId() {
+        return orderId;
+    }
+    
+    public void setOrderId(final long orderId) {
+        this.orderId = orderId;
+    }
+    
+    public int getUserId() {
+        return userId;
+    }
+    
+    public void setUserId(final int userId) {
+        this.userId = userId;
+    }
+    
+    public String getStatus() {
+        return status;
+    }
+    
+    public void setStatus(final String status) {
+        this.status = status;
+    }
+    
+    @Override
+    public String toString() {
+        return String.format("order_item_id:%s, order_id: %s, user_id: %s, 
status: %s", orderItemId, orderId, userId, status);
+    }
+}
diff --git 
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-db-discovery-example/shardingsphere-jdbc-memory-local-db-discovery-spring-boot-starter-mybatis-example/src/main/java/org/apache/shardingsphere/example/db/discovery/spring/boot/starter/mybatis/repository/OrderItemRepository.java
 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memor
 [...]
new file mode 100644
index 0000000..ad3bb6a
--- /dev/null
+++ 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-db-discovery-example/shardingsphere-jdbc-memory-local-db-discovery-spring-boot-starter-mybatis-example/src/main/java/org/apache/shardingsphere/example/db/discovery/spring/boot/starter/mybatis/repository/OrderItemRepository.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.db.discovery.spring.boot.starter.mybatis.repository;
+
+import org.apache.ibatis.annotations.Mapper;
+import 
org.apache.shardingsphere.example.db.discovery.spring.boot.starter.mybatis.entity.OrderItem;
+
+import java.util.List;
+
+@Mapper
+public interface OrderItemRepository {
+    
+    void createTableIfNotExists();
+    
+    void truncateTable();
+    
+    void dropTable();
+    
+    void insert(OrderItem orderItem);
+    
+    void delete(long orderId);
+    
+    List<OrderItem> selectAll();
+}
diff --git 
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-db-discovery-example/shardingsphere-jdbc-memory-local-db-discovery-spring-boot-starter-mybatis-example/src/main/java/org/apache/shardingsphere/example/db/discovery/spring/boot/starter/mybatis/repository/OrderRepository.java
 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-ex
 [...]
new file mode 100644
index 0000000..80b922c
--- /dev/null
+++ 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-db-discovery-example/shardingsphere-jdbc-memory-local-db-discovery-spring-boot-starter-mybatis-example/src/main/java/org/apache/shardingsphere/example/db/discovery/spring/boot/starter/mybatis/repository/OrderRepository.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.db.discovery.spring.boot.starter.mybatis.repository;
+
+import org.apache.ibatis.annotations.Mapper;
+import 
org.apache.shardingsphere.example.db.discovery.spring.boot.starter.mybatis.entity.Order;
+
+import java.util.List;
+
+@Mapper
+public interface OrderRepository {
+
+    void createTableIfNotExists();
+
+    void truncateTable();
+
+    void dropTable();
+
+    void insert(Order order);
+
+    void delete(long orderId);
+
+    List<Order> selectAll();
+}
diff --git 
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-db-discovery-example/shardingsphere-jdbc-memory-local-db-discovery-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
 [...]
new file mode 100644
index 0000000..ddfd88e
--- /dev/null
+++ 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-db-discovery-example/shardingsphere-jdbc-memory-local-db-discovery-spring-boot-starter-mybatis-example/src/main/resources/application.properties
@@ -0,0 +1,52 @@
+#
+# 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.names=ds-0,ds-0-replica-0,ds-0-replica-1
+
+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://172.72.0.15:3306/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-0-replica-0.type=com.zaxxer.hikari.HikariDataSource
+spring.shardingsphere.datasource.ds-0-replica-0.driver-class-name=com.mysql.jdbc.Driver
+spring.shardingsphere.datasource.ds-0-replica-0.jdbc-url=jdbc:mysql://172.72.0.16:3306/ds_0_replica_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+spring.shardingsphere.datasource.ds-0-replica-0.username=root
+spring.shardingsphere.datasource.ds-0-replica-0.password=root
+spring.shardingsphere.datasource.ds-0-replica-0.max-active=16
+
+spring.shardingsphere.datasource.ds-0-replica-1.type=com.zaxxer.hikari.HikariDataSource
+spring.shardingsphere.datasource.ds-0-replica-1.driver-class-name=com.mysql.jdbc.Driver
+spring.shardingsphere.datasource.ds-0-replica-1.jdbc-url=jdbc:mysql://172.72.0.17:3306/ds_0_replica_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
+spring.shardingsphere.datasource.ds-0-replica-1.username=root
+spring.shardingsphere.datasource.ds-0-replica-1.password=root
+spring.shardingsphere.datasource.ds-0-replica-1.max-active=16
+
+spring.shardingsphere.rules.database-discovery.data-sources.rule.data-source-names=ds-0,ds-0-replica-0,ds-0-replica-1
+spring.shardingsphere.rules.database-discovery.data-sources.rule.discovery-heartbeat-name=mgr-heartbeat
+spring.shardingsphere.rules.database-discovery.data-sources.rule.discovery-type-name=mgr
+spring.shardingsphere.rules.database-discovery.discovery-heartbeats.mgr-heartbeat.props.keep-alive-cron=0/5
 * * * * ?
+spring.shardingsphere.rules.database-discovery.discovery-types.mgr.type=MGR
+spring.shardingsphere.rules.database-discovery.discovery-types.mgr.props.keep-alive-cron=0/5
 * * * * ?
+spring.shardingsphere.rules.database-discovery.discovery-types.mgr.props.group-name=aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa
+
+
+
diff --git 
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-db-discovery-example/pom.xml
 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-db-discovery-example/shardingsphere-jdbc-memory-local-db-discovery-spring-boot-starter-mybatis-example/src/main/res
 [...]
similarity index 53%
copy from 
examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-db-discovery-example/pom.xml
copy to 
examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-db-discovery-example/shardingsphere-jdbc-memory-local-db-discovery-spring-boot-starter-mybatis-example/src/main/resources/logback.xml
index 68f1cde..154abba 100644
--- 
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-db-discovery-example/pom.xml
+++ 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-db-discovery-example/shardingsphere-jdbc-memory-local-db-discovery-spring-boot-starter-mybatis-example/src/main/resources/logback.xml
@@ -16,21 +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";>
-    <parent>
-        <artifactId>shardingsphere-jdbc-memory-local-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-db-discovery-example</artifactId>
-    <name>${project.artifactId}</name>
+<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>
     
-    <modules>
-        
<module>shardingsphere-jdbc-memory-local-db-discovery-jdbc-example</module>
-    </modules>
-    
-</project>
+    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder charset="${log.charset}">
+            <pattern>${log.pattern}</pattern>
+        </encoder>
+    </appender>
+    <root>
+        <level value="INFO" />
+        <appender-ref ref="STDOUT" />
+    </root>
+</configuration>
diff --git 
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-db-discovery-example/shardingsphere-jdbc-memory-local-db-discovery-spring-boot-starter-mybatis-example/src/main/resources/mappers/OrderItemMapper.xml
 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-
 [...]
new file mode 100644
index 0000000..fc8a73a
--- /dev/null
+++ 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-db-discovery-example/shardingsphere-jdbc-memory-local-db-discovery-spring-boot-starter-mybatis-example/src/main/resources/mappers/OrderItemMapper.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.db.discovery.spring.boot.starter.mybatis.repository.OrderItemRepository">
+    <resultMap id="baseResultMap" 
type="org.apache.shardingsphere.example.db.discovery.spring.boot.starter.mybatis.entity.OrderItem">
+        <result column="order_item_id" property="orderItemId" 
jdbcType="INTEGER"/>
+        <result column="order_id" property="orderId" jdbcType="INTEGER"/>
+        <result column="user_id" property="userId" jdbcType="INTEGER"/>
+        <result column="status" property="status" jdbcType="VARCHAR"/>
+    </resultMap>
+    
+    <update id="createTableIfNotExists">
+        CREATE TABLE IF NOT EXISTS t_order_item (order_item_id BIGINT 
AUTO_INCREMENT, order_id BIGINT, user_id INT NOT NULL, status VARCHAR(50) , 
PRIMARY KEY (order_item_id));
+    </update>
+    
+    <update id="truncateTable">
+        TRUNCATE TABLE t_order_item;
+    </update>
+    
+    <update id="dropTable">
+        DROP TABLE IF EXISTS t_order_item;
+    </update>
+    
+    <insert id="insert" useGeneratedKeys="true" keyProperty="orderItemId">
+        INSERT INTO t_order_item (order_id, user_id, status) VALUES 
(#{orderId,jdbcType=INTEGER}, #{userId,jdbcType=INTEGER}, 
#{status,jdbcType=VARCHAR});
+    </insert>
+    
+    <delete id="delete">
+        DELETE FROM t_order_item WHERE order_id = #{orderId,jdbcType=INTEGER};
+    </delete>
+    
+    <select id="selectAll" resultMap="baseResultMap">
+        SELECT * from t_order_item
+    </select>
+</mapper>
diff --git 
a/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-db-discovery-example/shardingsphere-jdbc-memory-local-db-discovery-spring-boot-starter-mybatis-example/src/main/resources/mappers/OrderMapper.xml
 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-loca
 [...]
new file mode 100644
index 0000000..f3a847b
--- /dev/null
+++ 
b/examples/shardingsphere-sample/shardingsphere-jdbc-sample/shardingsphere-jdbc-memory-example/shardingsphere-jdbc-memory-local-example/shardingsphere-jdbc-memory-local-db-discovery-example/shardingsphere-jdbc-memory-local-db-discovery-spring-boot-starter-mybatis-example/src/main/resources/mappers/OrderMapper.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.db.discovery.spring.boot.starter.mybatis.repository.OrderRepository">
+    <resultMap id="baseResultMap" 
type="org.apache.shardingsphere.example.db.discovery.spring.boot.starter.mybatis.entity.Order">
+        <result column="order_id" property="orderId" jdbcType="BIGINT"/>
+        <result column="user_id" property="userId" jdbcType="INTEGER"/>
+        <result column="address_id" property="addressId" jdbcType="BIGINT"/>
+        <result column="status" property="status" jdbcType="VARCHAR"/>
+    </resultMap>
+
+    <update id="createTableIfNotExists">
+        CREATE TABLE IF NOT EXISTS t_order (order_id BIGINT AUTO_INCREMENT, 
user_id INT NOT NULL, address_id BIGINT NOT NULL, status VARCHAR(50), PRIMARY 
KEY (order_id));
+    </update>
+    
+    <update id="truncateTable">
+        TRUNCATE TABLE t_order;
+    </update>
+    
+    <update id="dropTable">
+        DROP TABLE IF EXISTS t_order;
+    </update>
+    
+    <insert id="insert" useGeneratedKeys="true" keyProperty="orderId">
+        INSERT INTO t_order (user_id, address_id, status) VALUES 
(#{userId,jdbcType=INTEGER}, #{addressId,jdbcType=BIGINT}, 
#{status,jdbcType=VARCHAR});
+    </insert>
+    
+    <delete id="delete">
+        DELETE FROM t_order WHERE order_id = #{orderId,jdbcType=INTEGER};
+    </delete>
+    
+    <select id="selectAll" resultMap="baseResultMap">
+        SELECT * FROM t_order;
+    </select>
+</mapper>

Reply via email to