You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by al...@apache.org on 2023/02/07 08:36:11 UTC
[dubbo-samples] branch master updated: add dubbo + spring boot + mybatis & hibernate samples (#643)
This is an automated email from the ASF dual-hosted git repository.
albumenj pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo-samples.git
The following commit(s) were added to refs/heads/master by this push:
new 6c662a2e add dubbo + spring boot + mybatis & hibernate samples (#643)
6c662a2e is described below
commit 6c662a2e7e75114eed72eeab343fc4b9fb062810
Author: francisoyc <61...@qq.com>
AuthorDate: Tue Feb 7 16:36:03 2023 +0800
add dubbo + spring boot + mybatis & hibernate samples (#643)
---
99-integration/dubbo-samples-hibernate/README.md | 4 +-
.../dubbo-samples-hibernate/case-configuration.yml | 36 +++++++++--
.../dubbo-samples-hibernate/case-versions.conf | 7 +--
.../pom.xml} | 30 ++++++----
.../hibernate/samples}/HibernateService.java | 2 +-
.../dubbo/springboot/hibernate/samples}/User.java | 4 +-
.../pom.xml | 48 +++++++++++++++
.../samples/HibernateConsumerApplication.java} | 39 +++++++-----
.../src/main/resources/application.yml} | 21 ++++---
.../src/main/resources/log4j.properties | 7 +++
.../springboot/hibernate/samples/HibernateIT.java | 41 +++++++++++++
.../pom.xml | 62 +++++++++++++++++++
.../hibernate/samples}/EmbeddedZooKeeper.java | 2 +-
.../samples/HibernateProviderApplication.java} | 17 +++---
.../samples}/impl/HibernateServiceImpl.java | 25 ++++----
.../hibernate/samples/repository}/UserModel.java | 4 +-
.../samples/repository/UserRepository.java} | 10 ++--
.../src/main/resources/application.yml} | 29 ++++++---
.../resources/liquibase/liquibase-changelog.xml | 6 --
.../src/main/resources/log4j.properties | 7 +++
99-integration/dubbo-samples-hibernate/pom.xml | 61 +++++++------------
.../boundary/hibernate/HibernateConsumer.java | 42 -------------
.../boundary/hibernate/impl/dao/UserDaoImpl.java | 47 ---------------
.../src/main/resources/log4j.properties | 26 --------
.../main/resources/spring/hibernate-consumer.xml | 32 ----------
.../main/resources/spring/hibernate-provider.xml | 69 ----------------------
.../boundary/hibernate/HibernateServiceIT.java | 65 --------------------
99-integration/dubbo-samples-mybatis/README.md | 3 +-
.../dubbo-samples-mybatis/case-configuration.yml | 36 +++++++++--
.../dubbo-samples-mybatis/case-versions.conf | 5 +-
.../pom.xml} | 30 ++++++----
.../mybatis/samples}/MybatisService.java | 4 +-
.../dubbo/springboot/mybatis/samples}/User.java | 2 +-
.../pom.xml | 48 +++++++++++++++
.../samples/MybatisConsumerApplication.java} | 36 ++++++-----
.../src/main/resources/application.yml} | 21 ++++---
.../src/main/resources/log4j.properties | 7 +++
.../springboot/mybatis/samples/MybatisIT.java | 39 ++++++++++++
.../pom.xml | 67 +++++++++++++++++++++
.../mybatis/samples}/EmbeddedZooKeeper.java | 2 +-
.../samples/MybatisProviderApplication.java} | 16 ++---
.../springboot/mybatis/samples}/dao/UserDao.java | 4 +-
.../springboot/mybatis/samples}/dao/UserModel.java | 4 +-
.../mybatis/samples}/impl/MybatisServiceImpl.java | 24 ++++----
.../src/main/resources/application.yml} | 29 ++++++---
.../resources/liquibase/liquibase-changelog.xml | 0
.../src/main/resources/log4j.properties | 7 +++
.../src/main/resources/mapper/UserMapper.xml | 4 +-
99-integration/dubbo-samples-mybatis/pom.xml | 30 ++--------
.../samples/boundary/mybatis/MybatisConsumer.java | 40 -------------
.../src/main/resources/log4j.properties | 26 --------
.../spring/application-provider.properties | 12 ----
.../src/main/resources/spring/mybatis-consumer.xml | 33 -----------
.../samples/boundary/mybatis/MybatisServiceIT.java | 62 -------------------
54 files changed, 634 insertions(+), 700 deletions(-)
diff --git a/99-integration/dubbo-samples-hibernate/README.md b/99-integration/dubbo-samples-hibernate/README.md
index bf718087..c3cdd1bc 100644
--- a/99-integration/dubbo-samples-hibernate/README.md
+++ b/99-integration/dubbo-samples-hibernate/README.md
@@ -1,8 +1,6 @@
# Dubbo + Hibernate
-This is a dubbo + hibernate sample.
-
-In this sample, both provider and consumer are using xml as configuration.
+This is a dubbo + spring boot + hibernate sample.
Please aware that dubbo doesn't require
special hibernate version, but spring and hibernate does have some version requirement. So please make sure you are
diff --git a/99-integration/dubbo-samples-hibernate/case-configuration.yml b/99-integration/dubbo-samples-hibernate/case-configuration.yml
index 821c36f1..693210d8 100644
--- a/99-integration/dubbo-samples-hibernate/case-configuration.yml
+++ b/99-integration/dubbo-samples-hibernate/case-configuration.yml
@@ -14,11 +14,35 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from: app-builtin-zookeeper.yml
+services:
+ zookeeper:
+ image: zookeeper:latest
-props:
- project_name: dubbo-samples-hibernate
- main_class: org.apache.dubbo.samples.boundary.hibernate.HibernateProvider
- zookeeper_port: 2181
- dubbo_port: 20880
+ dubbo-samples-spring-boot-hibernate-provider:
+ type: app
+ basedir: dubbo-samples-spring-boot-hibernate-provider
+ mainClass: org.apache.dubbo.springboot.hibernate.samples.HibernateProviderApplication
+ systemProps:
+ - zookeeper.address=zookeeper
+ waitPortsBeforeRun:
+ - zookeeper:2181
+ checkPorts:
+ - 20880
+ checkLog: "dubbo service started"
+ depends_on:
+ - zookeeper
+
+ dubbo-samples-spring-boot-hibernate-consumer:
+ type: test
+ basedir: dubbo-samples-spring-boot-hibernate-consumer
+ tests:
+ - "**/*IT.class"
+ systemProps:
+ - zookeeper.address=zookeeper
+ waitPortsBeforeRun:
+ - zookeeper:2181
+ - dubbo-samples-spring-boot-hibernate-provider:20880
+ depends_on:
+ - zookeeper
+ - dubbo-samples-spring-boot-hibernate-provider
diff --git a/99-integration/dubbo-samples-hibernate/case-versions.conf b/99-integration/dubbo-samples-hibernate/case-versions.conf
index 28f07efd..32a2e5be 100644
--- a/99-integration/dubbo-samples-hibernate/case-versions.conf
+++ b/99-integration/dubbo-samples-hibernate/case-versions.conf
@@ -19,8 +19,7 @@
# Supported component versions of the test case
-# Spring app
-#dubbo.version=2.7.*, 3.*
-dubbo.version=4.*
-spring.version=4.*
+# SpringBoot app
+dubbo.version=2.7*, 3.1*
+spring-boot.version=2.*
java.version= [<= 11]
diff --git a/99-integration/dubbo-samples-mybatis/src/main/resources/mapper/UserMapper.xml b/99-integration/dubbo-samples-hibernate/dubbo-samples-spring-boot-hibernate-api/pom.xml
similarity index 53%
copy from 99-integration/dubbo-samples-mybatis/src/main/resources/mapper/UserMapper.xml
copy to 99-integration/dubbo-samples-hibernate/dubbo-samples-spring-boot-hibernate-api/pom.xml
index ba193d05..c0833545 100644
--- a/99-integration/dubbo-samples-mybatis/src/main/resources/mapper/UserMapper.xml
+++ b/99-integration/dubbo-samples-hibernate/dubbo-samples-spring-boot-hibernate-api/pom.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
@@ -15,17 +15,21 @@
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.dubbo.samples.boundary.mybatis.impl.dao.UserDao">
+<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>dubbo-samples-hibernate</artifactId>
+ <groupId>org.apache.dubbo</groupId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
- <resultMap id="BASE_RESULT" type="org.apache.dubbo.samples.boundary.mybatis.impl.dao.UserModel">
- <id column="id" property="id"/>
- <result column="name" property="name"/>
- </resultMap>
- <select id="findByUserId" resultMap="BASE_RESULT">
- SELECT id, name
- FROM user
- where id = #{userId}
- </select>
+ <artifactId>dubbo-samples-spring-boot-hibernate-api</artifactId>
-</mapper>
+ <properties>
+ <maven.compiler.source>8</maven.compiler.source>
+ <maven.compiler.target>8</maven.compiler.target>
+ </properties>
+
+</project>
\ No newline at end of file
diff --git a/99-integration/dubbo-samples-hibernate/src/main/java/org/apache/dubbo/samples/boundary/hibernate/api/HibernateService.java b/99-integration/dubbo-samples-hibernate/dubbo-samples-spring-boot-hibernate-api/src/main/java/org/apache/dubbo/springboot/hibernate/samples/HibernateService.java
similarity index 94%
rename from 99-integration/dubbo-samples-hibernate/src/main/java/org/apache/dubbo/samples/boundary/hibernate/api/HibernateService.java
rename to 99-integration/dubbo-samples-hibernate/dubbo-samples-spring-boot-hibernate-api/src/main/java/org/apache/dubbo/springboot/hibernate/samples/HibernateService.java
index 2e3e5eb7..98ffe06d 100644
--- a/99-integration/dubbo-samples-hibernate/src/main/java/org/apache/dubbo/samples/boundary/hibernate/api/HibernateService.java
+++ b/99-integration/dubbo-samples-hibernate/dubbo-samples-spring-boot-hibernate-api/src/main/java/org/apache/dubbo/springboot/hibernate/samples/HibernateService.java
@@ -17,7 +17,7 @@
*
*/
-package org.apache.dubbo.samples.boundary.hibernate.api;
+package org.apache.dubbo.springboot.hibernate.samples;
import java.util.List;
diff --git a/99-integration/dubbo-samples-hibernate/src/main/java/org/apache/dubbo/samples/boundary/hibernate/api/User.java b/99-integration/dubbo-samples-hibernate/dubbo-samples-spring-boot-hibernate-api/src/main/java/org/apache/dubbo/springboot/hibernate/samples/User.java
similarity index 92%
rename from 99-integration/dubbo-samples-hibernate/src/main/java/org/apache/dubbo/samples/boundary/hibernate/api/User.java
rename to 99-integration/dubbo-samples-hibernate/dubbo-samples-spring-boot-hibernate-api/src/main/java/org/apache/dubbo/springboot/hibernate/samples/User.java
index 244d68ca..371437cc 100644
--- a/99-integration/dubbo-samples-hibernate/src/main/java/org/apache/dubbo/samples/boundary/hibernate/api/User.java
+++ b/99-integration/dubbo-samples-hibernate/dubbo-samples-spring-boot-hibernate-api/src/main/java/org/apache/dubbo/springboot/hibernate/samples/User.java
@@ -17,12 +17,12 @@
*
*/
-package org.apache.dubbo.samples.boundary.hibernate.api;
+package org.apache.dubbo.springboot.hibernate.samples;
import lombok.Data;
@Data
public class User implements java.io.Serializable {
- private long id;
+ private Long id;
private String name;
}
diff --git a/99-integration/dubbo-samples-hibernate/dubbo-samples-spring-boot-hibernate-consumer/pom.xml b/99-integration/dubbo-samples-hibernate/dubbo-samples-spring-boot-hibernate-consumer/pom.xml
new file mode 100644
index 00000000..35ab99f4
--- /dev/null
+++ b/99-integration/dubbo-samples-hibernate/dubbo-samples-spring-boot-hibernate-consumer/pom.xml
@@ -0,0 +1,48 @@
+<?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>dubbo-samples-hibernate</artifactId>
+ <groupId>org.apache.dubbo</groupId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>dubbo-samples-spring-boot-hibernate-consumer</artifactId>
+
+ <properties>
+ <maven.compiler.source>8</maven.compiler.source>
+ <maven.compiler.target>8</maven.compiler.target>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-samples-spring-boot-hibernate-api</artifactId>
+ <version>${project.parent.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
diff --git a/99-integration/dubbo-samples-mybatis/src/main/java/org/apache/dubbo/samples/boundary/mybatis/MybatisProvider.java b/99-integration/dubbo-samples-hibernate/dubbo-samples-spring-boot-hibernate-consumer/src/main/java/org/apache/dubbo/springboot/hibernate/samples/HibernateConsumerApplication.java
similarity index 52%
copy from 99-integration/dubbo-samples-mybatis/src/main/java/org/apache/dubbo/samples/boundary/mybatis/MybatisProvider.java
copy to 99-integration/dubbo-samples-hibernate/dubbo-samples-spring-boot-hibernate-consumer/src/main/java/org/apache/dubbo/springboot/hibernate/samples/HibernateConsumerApplication.java
index 73d0f607..94fbbcaa 100644
--- a/99-integration/dubbo-samples-mybatis/src/main/java/org/apache/dubbo/samples/boundary/mybatis/MybatisProvider.java
+++ b/99-integration/dubbo-samples-hibernate/dubbo-samples-spring-boot-hibernate-consumer/src/main/java/org/apache/dubbo/springboot/hibernate/samples/HibernateConsumerApplication.java
@@ -17,30 +17,39 @@
*
*/
-package org.apache.dubbo.samples.boundary.mybatis;
-import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
+package org.apache.dubbo.springboot.hibernate.samples;
-import org.mybatis.spring.annotation.MapperScan;
-import org.springframework.boot.CommandLineRunner;
+import org.apache.dubbo.config.annotation.DubboReference;
+import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.context.annotation.PropertySource;
+import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.stereotype.Service;
-@SpringBootApplication
+import java.util.List;
+
+@Service
@EnableDubbo
-@MapperScan("org.apache.dubbo.samples.boundary.mybatis")
-@PropertySource("classpath:spring/application-provider.properties")
-public class MybatisProvider implements CommandLineRunner {
+@SpringBootApplication(exclude={DataSourceAutoConfiguration.class})
+public class HibernateConsumerApplication {
- public static void main(String[] args) throws Exception {
- new EmbeddedZooKeeper(2181, false).start();
+ @DubboReference
+ private HibernateService hibernateService;
- SpringApplication.run(MybatisProvider.class, args);
+ public static void main(String[] args) {
+ ConfigurableApplicationContext context = SpringApplication.run(HibernateConsumerApplication.class, args);
+ HibernateConsumerApplication application = context.getBean(HibernateConsumerApplication.class);
+ List<User> userList = application.findAll();
+ System.out.println("result: " + userList);
}
- @Override
- public void run(String... args) throws Exception {
- System.out.println("dubbo service started");
+ public List<User> findAll() {
+ return hibernateService.findAll();
}
}
+
+
+
+
diff --git a/99-integration/dubbo-samples-hibernate/case-configuration.yml b/99-integration/dubbo-samples-hibernate/dubbo-samples-spring-boot-hibernate-consumer/src/main/resources/application.yml
similarity index 67%
copy from 99-integration/dubbo-samples-hibernate/case-configuration.yml
copy to 99-integration/dubbo-samples-hibernate/dubbo-samples-spring-boot-hibernate-consumer/src/main/resources/application.yml
index 821c36f1..346a891d 100644
--- a/99-integration/dubbo-samples-hibernate/case-configuration.yml
+++ b/99-integration/dubbo-samples-hibernate/dubbo-samples-spring-boot-hibernate-consumer/src/main/resources/application.yml
@@ -14,11 +14,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from: app-builtin-zookeeper.yml
-
-props:
- project_name: dubbo-samples-hibernate
- main_class: org.apache.dubbo.samples.boundary.hibernate.HibernateProvider
- zookeeper_port: 2181
- dubbo_port: 20880
-
+dubbo:
+ application:
+ name: dubbo-samples-spring-boot-hibernate-consumer
+ protocol:
+ name: dubbo
+ port: 20081
+ registry:
+ id: zk-registry
+ address: zookeeper://${zookeeper.address:127.0.0.1}:2181
+ config-center:
+ address: zookeeper://${zookeeper.address:127.0.0.1}:2181
+ metadata-report:
+ address: zookeeper://${zookeeper.address:127.0.0.1}:2181
diff --git a/99-integration/dubbo-samples-hibernate/dubbo-samples-spring-boot-hibernate-consumer/src/main/resources/log4j.properties b/99-integration/dubbo-samples-hibernate/dubbo-samples-spring-boot-hibernate-consumer/src/main/resources/log4j.properties
new file mode 100644
index 00000000..8de4c4fd
--- /dev/null
+++ b/99-integration/dubbo-samples-hibernate/dubbo-samples-spring-boot-hibernate-consumer/src/main/resources/log4j.properties
@@ -0,0 +1,7 @@
+###set log levels###
+log4j.rootLogger=info, stdout
+###output to the console###
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.Target=System.out
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=[%d{dd/MM/yy HH:mm:ss:SSS z}] %t %5p %c{2}: %m%n
diff --git a/99-integration/dubbo-samples-hibernate/dubbo-samples-spring-boot-hibernate-consumer/src/test/java/org/apache/dubbo/springboot/hibernate/samples/HibernateIT.java b/99-integration/dubbo-samples-hibernate/dubbo-samples-spring-boot-hibernate-consumer/src/test/java/org/apache/dubbo/springboot/hibernate/samples/HibernateIT.java
new file mode 100644
index 00000000..521d86c4
--- /dev/null
+++ b/99-integration/dubbo-samples-hibernate/dubbo-samples-spring-boot-hibernate-consumer/src/test/java/org/apache/dubbo/springboot/hibernate/samples/HibernateIT.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.dubbo.springboot.hibernate.samples;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import java.util.List;
+
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = {HibernateConsumerApplication.class})
+public class HibernateIT {
+ @Autowired
+ private HibernateConsumerApplication consumerApplication;
+
+ @Test
+ public void test() throws Exception {
+ List<User> users = consumerApplication.findAll();
+ Assert.assertEquals(1, users.size());
+ }
+}
diff --git a/99-integration/dubbo-samples-hibernate/dubbo-samples-spring-boot-hibernate-provider/pom.xml b/99-integration/dubbo-samples-hibernate/dubbo-samples-spring-boot-hibernate-provider/pom.xml
new file mode 100644
index 00000000..22f5c92f
--- /dev/null
+++ b/99-integration/dubbo-samples-hibernate/dubbo-samples-spring-boot-hibernate-provider/pom.xml
@@ -0,0 +1,62 @@
+<?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>dubbo-samples-hibernate</artifactId>
+ <groupId>org.apache.dubbo</groupId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>dubbo-samples-spring-boot-hibernate-provider</artifactId>
+
+ <properties>
+ <maven.compiler.source>8</maven.compiler.source>
+ <maven.compiler.target>8</maven.compiler.target>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-samples-spring-boot-hibernate-api</artifactId>
+ <version>${project.parent.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <version>1.4.200</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.alibaba</groupId>
+ <artifactId>druid</artifactId>
+ <version>1.2.6</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.liquibase</groupId>
+ <artifactId>liquibase-core</artifactId>
+ <version>4.4.0</version>
+ </dependency>
+
+ </dependencies>
+</project>
\ No newline at end of file
diff --git a/99-integration/dubbo-samples-mybatis/src/main/java/org/apache/dubbo/samples/boundary/mybatis/EmbeddedZooKeeper.java b/99-integration/dubbo-samples-hibernate/dubbo-samples-spring-boot-hibernate-provider/src/main/java/org/apache/dubbo/springboot/hibernate/samples/EmbeddedZooKeeper.java
similarity index 99%
rename from 99-integration/dubbo-samples-mybatis/src/main/java/org/apache/dubbo/samples/boundary/mybatis/EmbeddedZooKeeper.java
rename to 99-integration/dubbo-samples-hibernate/dubbo-samples-spring-boot-hibernate-provider/src/main/java/org/apache/dubbo/springboot/hibernate/samples/EmbeddedZooKeeper.java
index ae4c712f..722e8e2f 100644
--- a/99-integration/dubbo-samples-mybatis/src/main/java/org/apache/dubbo/samples/boundary/mybatis/EmbeddedZooKeeper.java
+++ b/99-integration/dubbo-samples-hibernate/dubbo-samples-spring-boot-hibernate-provider/src/main/java/org/apache/dubbo/springboot/hibernate/samples/EmbeddedZooKeeper.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.samples.boundary.mybatis;
+package org.apache.dubbo.springboot.hibernate.samples;
import org.apache.zookeeper.server.ServerConfig;
import org.apache.zookeeper.server.ZooKeeperServerMain;
diff --git a/99-integration/dubbo-samples-hibernate/src/main/java/org/apache/dubbo/samples/boundary/hibernate/HibernateProvider.java b/99-integration/dubbo-samples-hibernate/dubbo-samples-spring-boot-hibernate-provider/src/main/java/org/apache/dubbo/springboot/hibernate/samples/HibernateProviderApplication.java
similarity index 71%
rename from 99-integration/dubbo-samples-hibernate/src/main/java/org/apache/dubbo/samples/boundary/hibernate/HibernateProvider.java
rename to 99-integration/dubbo-samples-hibernate/dubbo-samples-spring-boot-hibernate-provider/src/main/java/org/apache/dubbo/springboot/hibernate/samples/HibernateProviderApplication.java
index 9ae1839f..d0cf3ba6 100644
--- a/99-integration/dubbo-samples-hibernate/src/main/java/org/apache/dubbo/samples/boundary/hibernate/HibernateProvider.java
+++ b/99-integration/dubbo-samples-hibernate/dubbo-samples-spring-boot-hibernate-provider/src/main/java/org/apache/dubbo/springboot/hibernate/samples/HibernateProviderApplication.java
@@ -17,21 +17,20 @@
*
*/
-package org.apache.dubbo.samples.boundary.hibernate;
+package org.apache.dubbo.springboot.hibernate.samples;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
+import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
-import java.util.concurrent.CountDownLatch;
-public class HibernateProvider {
+@EnableDubbo
+@SpringBootApplication
+public class HibernateProviderApplication {
public static void main(String[] args) throws Exception {
new EmbeddedZooKeeper(2181, false).start();
-
- ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/hibernate-provider.xml");
- context.start();
-
+ SpringApplication.run(HibernateProviderApplication.class, args);
System.out.println("dubbo service started");
- new CountDownLatch(1).await();
}
}
diff --git a/99-integration/dubbo-samples-hibernate/src/main/java/org/apache/dubbo/samples/boundary/hibernate/impl/HibernateServiceImpl.java b/99-integration/dubbo-samples-hibernate/dubbo-samples-spring-boot-hibernate-provider/src/main/java/org/apache/dubbo/springboot/hibernate/samples/impl/HibernateServiceImpl.java
similarity index 71%
rename from 99-integration/dubbo-samples-hibernate/src/main/java/org/apache/dubbo/samples/boundary/hibernate/impl/HibernateServiceImpl.java
rename to 99-integration/dubbo-samples-hibernate/dubbo-samples-spring-boot-hibernate-provider/src/main/java/org/apache/dubbo/springboot/hibernate/samples/impl/HibernateServiceImpl.java
index b13f487c..8debb65b 100644
--- a/99-integration/dubbo-samples-hibernate/src/main/java/org/apache/dubbo/samples/boundary/hibernate/impl/HibernateServiceImpl.java
+++ b/99-integration/dubbo-samples-hibernate/dubbo-samples-spring-boot-hibernate-provider/src/main/java/org/apache/dubbo/springboot/hibernate/samples/impl/HibernateServiceImpl.java
@@ -30,32 +30,37 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.samples.boundary.hibernate.impl;
-
-import org.apache.dubbo.samples.boundary.hibernate.api.HibernateService;
-import org.apache.dubbo.samples.boundary.hibernate.api.User;
-import org.apache.dubbo.samples.boundary.hibernate.impl.dao.UserDao;
-import org.apache.dubbo.samples.boundary.hibernate.impl.dao.UserModel;
+package org.apache.dubbo.springboot.hibernate.samples.impl;
+import org.apache.dubbo.config.annotation.DubboService;
+import org.apache.dubbo.springboot.hibernate.samples.HibernateService;
+import org.apache.dubbo.springboot.hibernate.samples.User;
+import org.apache.dubbo.springboot.hibernate.samples.repository.UserRepository;
+import org.apache.dubbo.springboot.hibernate.samples.repository.UserModel;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;
+@Service
+@DubboService
public class HibernateServiceImpl implements HibernateService {
@Autowired
- private UserDao userDao;
+ private UserRepository userRepository;
@Override
public List<User> findAll() {
- List<UserModel> userModels = userDao.findAll();
+ UserModel userModel = new UserModel();
+ userModel.setId(1L);
+ userModel.setName("apache dubbo");
+ userRepository.saveAndFlush(userModel);
+ List<UserModel> userModels = userRepository.findAll();
return userModels.stream().map(u -> {
User user = new User();
-
user.setId(u.getId());
user.setName(u.getName());
-
return user;
}).collect(Collectors.toList());
}
diff --git a/99-integration/dubbo-samples-hibernate/src/main/java/org/apache/dubbo/samples/boundary/hibernate/impl/dao/UserModel.java b/99-integration/dubbo-samples-hibernate/dubbo-samples-spring-boot-hibernate-provider/src/main/java/org/apache/dubbo/springboot/hibernate/samples/repository/UserModel.java
similarity index 93%
rename from 99-integration/dubbo-samples-hibernate/src/main/java/org/apache/dubbo/samples/boundary/hibernate/impl/dao/UserModel.java
rename to 99-integration/dubbo-samples-hibernate/dubbo-samples-spring-boot-hibernate-provider/src/main/java/org/apache/dubbo/springboot/hibernate/samples/repository/UserModel.java
index a1b6153b..98049ca0 100644
--- a/99-integration/dubbo-samples-hibernate/src/main/java/org/apache/dubbo/samples/boundary/hibernate/impl/dao/UserModel.java
+++ b/99-integration/dubbo-samples-hibernate/dubbo-samples-spring-boot-hibernate-provider/src/main/java/org/apache/dubbo/springboot/hibernate/samples/repository/UserModel.java
@@ -17,7 +17,7 @@
*
*/
-package org.apache.dubbo.samples.boundary.hibernate.impl.dao;
+package org.apache.dubbo.springboot.hibernate.samples.repository;
import lombok.Data;
@@ -34,7 +34,7 @@ import javax.persistence.Table;
public class UserModel {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
- private long id;
+ private Long id;
@Column(name = "name", nullable = false)
private String name;
}
diff --git a/99-integration/dubbo-samples-hibernate/src/main/java/org/apache/dubbo/samples/boundary/hibernate/impl/dao/UserDao.java b/99-integration/dubbo-samples-hibernate/dubbo-samples-spring-boot-hibernate-provider/src/main/java/org/apache/dubbo/springboot/hibernate/samples/repository/UserRepository.java
similarity index 76%
rename from 99-integration/dubbo-samples-hibernate/src/main/java/org/apache/dubbo/samples/boundary/hibernate/impl/dao/UserDao.java
rename to 99-integration/dubbo-samples-hibernate/dubbo-samples-spring-boot-hibernate-provider/src/main/java/org/apache/dubbo/springboot/hibernate/samples/repository/UserRepository.java
index 9932aa21..8f4b8bc9 100644
--- a/99-integration/dubbo-samples-hibernate/src/main/java/org/apache/dubbo/samples/boundary/hibernate/impl/dao/UserDao.java
+++ b/99-integration/dubbo-samples-hibernate/dubbo-samples-spring-boot-hibernate-provider/src/main/java/org/apache/dubbo/springboot/hibernate/samples/repository/UserRepository.java
@@ -17,12 +17,12 @@
*
*/
-package org.apache.dubbo.samples.boundary.hibernate.impl.dao;
+package org.apache.dubbo.springboot.hibernate.samples.repository;
-import java.util.List;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
-public interface UserDao {
- List<UserModel> findAll();
+@Repository
+public interface UserRepository extends JpaRepository<UserModel, Long> {
- void saveUserModel(UserModel userModel);
}
diff --git a/99-integration/dubbo-samples-hibernate/case-configuration.yml b/99-integration/dubbo-samples-hibernate/dubbo-samples-spring-boot-hibernate-provider/src/main/resources/application.yml
similarity index 52%
copy from 99-integration/dubbo-samples-hibernate/case-configuration.yml
copy to 99-integration/dubbo-samples-hibernate/dubbo-samples-spring-boot-hibernate-provider/src/main/resources/application.yml
index 821c36f1..7baf8838 100644
--- a/99-integration/dubbo-samples-hibernate/case-configuration.yml
+++ b/99-integration/dubbo-samples-hibernate/dubbo-samples-spring-boot-hibernate-provider/src/main/resources/application.yml
@@ -14,11 +14,26 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from: app-builtin-zookeeper.yml
-
-props:
- project_name: dubbo-samples-hibernate
- main_class: org.apache.dubbo.samples.boundary.hibernate.HibernateProvider
- zookeeper_port: 2181
- dubbo_port: 20880
+dubbo:
+ application:
+ name: dubbo-samples-spring-boot-hibernate-provider
+ protocol:
+ name: dubbo
+ port: 20880
+ registry:
+ id: zk-registry
+ address: zookeeper://${zookeeper.address:127.0.0.1}:2181
+ config-center:
+ address: zookeeper://${zookeeper.address:127.0.0.1}:2181
+ metadata-report:
+ address: zookeeper://${zookeeper.address:127.0.0.1}:2181
+ scan:
+ base-packages: org.apache.dubbo.springboot.hibernate.samples
+spring:
+ liquibase:
+ change-log: liquibase/liquibase-changelog.xml
+ datasource:
+ type: com.alibaba.druid.pool.DruidDataSource
+ driver-class-name: org.h2.Driver
+ url: jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1;MODE=Oracle;TRACE_LEVEL_SYSTEM_OUT=2;DATABASE_TO_LOWER=TRUE
\ No newline at end of file
diff --git a/99-integration/dubbo-samples-mybatis/src/main/resources/liquibase/liquibase-changelog.xml b/99-integration/dubbo-samples-hibernate/dubbo-samples-spring-boot-hibernate-provider/src/main/resources/liquibase/liquibase-changelog.xml
similarity index 89%
rename from 99-integration/dubbo-samples-mybatis/src/main/resources/liquibase/liquibase-changelog.xml
rename to 99-integration/dubbo-samples-hibernate/dubbo-samples-spring-boot-hibernate-provider/src/main/resources/liquibase/liquibase-changelog.xml
index b468536c..e3b496fb 100644
--- a/99-integration/dubbo-samples-mybatis/src/main/resources/liquibase/liquibase-changelog.xml
+++ b/99-integration/dubbo-samples-hibernate/dubbo-samples-spring-boot-hibernate-provider/src/main/resources/liquibase/liquibase-changelog.xml
@@ -28,10 +28,4 @@
<column name="name" type="varchar(50)"/>
</createTable>
</changeSet>
-
- <changeSet author="add-test-data" id="htynkn">
- <insert tableName="user">
- <column name="name" value="apache dubbo"/>
- </insert>
- </changeSet>
</databaseChangeLog>
diff --git a/99-integration/dubbo-samples-hibernate/dubbo-samples-spring-boot-hibernate-provider/src/main/resources/log4j.properties b/99-integration/dubbo-samples-hibernate/dubbo-samples-spring-boot-hibernate-provider/src/main/resources/log4j.properties
new file mode 100644
index 00000000..8de4c4fd
--- /dev/null
+++ b/99-integration/dubbo-samples-hibernate/dubbo-samples-spring-boot-hibernate-provider/src/main/resources/log4j.properties
@@ -0,0 +1,7 @@
+###set log levels###
+log4j.rootLogger=info, stdout
+###output to the console###
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.Target=System.out
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=[%d{dd/MM/yy HH:mm:ss:SSS z}] %t %5p %c{2}: %m%n
diff --git a/99-integration/dubbo-samples-hibernate/pom.xml b/99-integration/dubbo-samples-hibernate/pom.xml
index cde9a388..4a940d05 100644
--- a/99-integration/dubbo-samples-hibernate/pom.xml
+++ b/99-integration/dubbo-samples-hibernate/pom.xml
@@ -20,6 +20,12 @@
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
+ <packaging>pom</packaging>
+ <modules>
+ <module>dubbo-samples-spring-boot-hibernate-api</module>
+ <module>dubbo-samples-spring-boot-hibernate-provider</module>
+ <module>dubbo-samples-spring-boot-hibernate-consumer</module>
+ </modules>
<parent>
<groupId>org.apache</groupId>
<artifactId>apache</artifactId>
@@ -39,17 +45,16 @@
<dubbo.version>3.0.7</dubbo.version>
<spring.version>4.3.29.RELEASE</spring.version>
<junit.version>4.13.1</junit.version>
- <spring.version>4.3.29.RELEASE</spring.version>
+ <spring-boot.version>2.4.1</spring-boot.version>
<maven-compiler-plugin.version>3.7.0</maven-compiler-plugin.version>
- <hibernate.version>4.3.6.Final</hibernate.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-framework-bom</artifactId>
- <version>${spring.version}</version>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-dependencies</artifactId>
+ <version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
@@ -71,39 +76,14 @@
<dependencies>
<dependency>
- <groupId>com.h2database</groupId>
- <artifactId>h2</artifactId>
- <version>1.4.200</version>
- </dependency>
-
- <dependency>
- <groupId>com.alibaba</groupId>
- <artifactId>druid</artifactId>
- <version>1.2.6</version>
- </dependency>
-
- <dependency>
- <groupId>org.liquibase</groupId>
- <artifactId>liquibase-core</artifactId>
- <version>4.4.0</version>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-orm</artifactId>
- <version>${spring.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-context</artifactId>
- <version>${spring.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-core</artifactId>
- <version>${hibernate.version}</version>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-spring-boot-starter</artifactId>
+ <version>${dubbo.version}</version>
</dependency>
<dependency>
@@ -112,12 +92,6 @@
<type>pom</type>
</dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo</artifactId>
- <version>${dubbo.version}</version>
- </dependency>
-
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
@@ -137,6 +111,11 @@
<version>1.18.20</version>
<scope>provided</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-data-jpa</artifactId>
+ </dependency>
</dependencies>
<profiles>
diff --git a/99-integration/dubbo-samples-hibernate/src/main/java/org/apache/dubbo/samples/boundary/hibernate/HibernateConsumer.java b/99-integration/dubbo-samples-hibernate/src/main/java/org/apache/dubbo/samples/boundary/hibernate/HibernateConsumer.java
deleted file mode 100644
index b7eb1e79..00000000
--- a/99-integration/dubbo-samples-hibernate/src/main/java/org/apache/dubbo/samples/boundary/hibernate/HibernateConsumer.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- *
- * 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.dubbo.samples.boundary.hibernate;
-
-import org.apache.dubbo.samples.boundary.hibernate.api.HibernateService;
-import org.apache.dubbo.samples.boundary.hibernate.api.User;
-
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-import java.util.List;
-
-public class HibernateConsumer {
-
- public static void main(String[] args) throws Exception {
- ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/hibernate-consumer.xml");
- context.start();
-
- HibernateService hibernateService = context.getBean(HibernateService.class);
-
- for (int i = 0; i < 5; i++) {
- List<User> users = hibernateService.findAll();
- System.out.println("find users: " + users);
- }
- }
-}
diff --git a/99-integration/dubbo-samples-hibernate/src/main/java/org/apache/dubbo/samples/boundary/hibernate/impl/dao/UserDaoImpl.java b/99-integration/dubbo-samples-hibernate/src/main/java/org/apache/dubbo/samples/boundary/hibernate/impl/dao/UserDaoImpl.java
deleted file mode 100644
index 8e82c677..00000000
--- a/99-integration/dubbo-samples-hibernate/src/main/java/org/apache/dubbo/samples/boundary/hibernate/impl/dao/UserDaoImpl.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- *
- * 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.dubbo.samples.boundary.hibernate.impl.dao;
-
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Repository;
-
-import java.util.List;
-
-@Repository(value = "userDao")
-public class UserDaoImpl implements UserDao {
- @Autowired
- private SessionFactory sessionFactory;
-
- @Override
- public List<UserModel> findAll() {
- return sessionFactory.openSession().createCriteria(UserModel.class).list();
- }
-
- @Override
- public void saveUserModel(UserModel userModel) {
- Session session = sessionFactory.openSession();
-
- session.save(userModel);
-
- session.close();
- }
-}
diff --git a/99-integration/dubbo-samples-hibernate/src/main/resources/log4j.properties b/99-integration/dubbo-samples-hibernate/src/main/resources/log4j.properties
deleted file mode 100644
index d6ecd5ce..00000000
--- a/99-integration/dubbo-samples-hibernate/src/main/resources/log4j.properties
+++ /dev/null
@@ -1,26 +0,0 @@
-#
-#
-# 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.
-#
-#
-
-###set log levels###
-log4j.rootLogger=info, stdout
-###output to the console###
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.Target=System.out
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=[%d{dd/MM/yy hh:mm:ss:sss z}] %t %5p %c{2}: %m%n
\ No newline at end of file
diff --git a/99-integration/dubbo-samples-hibernate/src/main/resources/spring/hibernate-consumer.xml b/99-integration/dubbo-samples-hibernate/src/main/resources/spring/hibernate-consumer.xml
deleted file mode 100644
index 7fb555e3..00000000
--- a/99-integration/dubbo-samples-hibernate/src/main/resources/spring/hibernate-consumer.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?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.
- -->
-
-<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:dubbo="http://dubbo.apache.org/schema/dubbo"
- xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
- http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
- <context:property-placeholder/>
-
- <dubbo:application name="hibernate-consumer"/>
-
- <dubbo:registry address="zookeeper://${zookeeper.address:127.0.0.1}:${zookeeper.port:2181}"/>
-
- <dubbo:reference id="hibernateService" interface="org.apache.dubbo.samples.boundary.hibernate.api.HibernateService"/>
-
-</beans>
diff --git a/99-integration/dubbo-samples-hibernate/src/main/resources/spring/hibernate-provider.xml b/99-integration/dubbo-samples-hibernate/src/main/resources/spring/hibernate-provider.xml
deleted file mode 100644
index 7edc7084..00000000
--- a/99-integration/dubbo-samples-hibernate/src/main/resources/spring/hibernate-provider.xml
+++ /dev/null
@@ -1,69 +0,0 @@
-<?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.
- -->
-
-<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:dubbo="http://dubbo.apache.org/schema/dubbo"
- xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context"
- xmlns:tx="http://www.springframework.org/schema/tx"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
- http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
- <context:property-placeholder/>
-
- <dubbo:application name="hibernate-provider"/>
-
- <dubbo:registry address="zookeeper://${zookeeper.address:127.0.0.1}:${zookeeper.port:2181}"/>
-
- <dubbo:provider token="true"/>
-
- <dubbo:protocol name="dubbo" port="20880"/>
-
- <bean id="hibernateService" class="org.apache.dubbo.samples.boundary.hibernate.impl.HibernateServiceImpl"/>
-
- <dubbo:service interface="org.apache.dubbo.samples.boundary.hibernate.api.HibernateService" ref="hibernateService"/>
-
-
- <context:component-scan base-package="org.apache.dubbo.samples.boundary.hibernate.impl.dao"/>
-
- <bean name="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
- <property name="driverClassName" value="org.h2.Driver"/>
- <property name="url" value="jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1;MODE=Oracle;TRACE_LEVEL_SYSTEM_OUT=2"/>
- </bean>
-
- <bean id="liquibase" class="liquibase.integration.spring.SpringLiquibase">
- <property name="dataSource" ref="dataSource"/>
- <property name="changeLog" value="classpath:liquibase/liquibase-changelog.xml"/>
- </bean>
-
- <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
- <property name="dataSource" ref="dataSource"/>
- <property name="packagesToScan" value="org.apache.dubbo.samples.boundary.hibernate.impl.dao"/>
- <property name="hibernateProperties">
- <props>
- <prop key="hibernate.dialect">org.hibernate.dialect.H2Dialect</prop>
- <prop key="hibernate.show_sql">true</prop>
- <prop key="hibernate.format_sql">true</prop>
- </props>
- </property>
- </bean>
-
- <bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
- <property name="sessionFactory" ref="sessionFactory"/>
- </bean>
-
- <tx:annotation-driven transaction-manager="transactionManager"/>
-</beans>
diff --git a/99-integration/dubbo-samples-hibernate/src/test/java/org/apache/dubbo/samples/boundary/hibernate/HibernateServiceIT.java b/99-integration/dubbo-samples-hibernate/src/test/java/org/apache/dubbo/samples/boundary/hibernate/HibernateServiceIT.java
deleted file mode 100644
index 2a5b05bc..00000000
--- a/99-integration/dubbo-samples-hibernate/src/test/java/org/apache/dubbo/samples/boundary/hibernate/HibernateServiceIT.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * 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.
- */
-
-/*
- * Copyright 2014 the original author or authors.
- *
- * Licensed 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.dubbo.samples.boundary.hibernate;
-
-import org.apache.dubbo.samples.boundary.hibernate.api.HibernateService;
-import org.apache.dubbo.samples.boundary.hibernate.api.User;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-import java.util.List;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.not;
-import static org.hamcrest.CoreMatchers.nullValue;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations = "classpath*:spring/hibernate-consumer.xml")
-public class HibernateServiceIT {
- @Autowired
- private HibernateService service;
-
- @Test
- public void shouldGetDataFromHibernate() throws Exception {
- List<User> users = service.findAll();
-
- assertThat(users, not(nullValue()));
- assertThat(users.size(), is(1));
- assertThat(users.get(0).getName(), is("apache dubbo"));
- }
-}
diff --git a/99-integration/dubbo-samples-mybatis/README.md b/99-integration/dubbo-samples-mybatis/README.md
index 5750aa16..77347856 100644
--- a/99-integration/dubbo-samples-mybatis/README.md
+++ b/99-integration/dubbo-samples-mybatis/README.md
@@ -1,6 +1,5 @@
# Dubbo + Mybatis
-This is a dubbo + mybatis sample.
+This is a dubbo + spring boot + mybatis sample.
-In this sample, provider is using @ComponentScan and consumer is using xml configuration.
diff --git a/99-integration/dubbo-samples-mybatis/case-configuration.yml b/99-integration/dubbo-samples-mybatis/case-configuration.yml
index 09f661f4..91704126 100644
--- a/99-integration/dubbo-samples-mybatis/case-configuration.yml
+++ b/99-integration/dubbo-samples-mybatis/case-configuration.yml
@@ -14,11 +14,35 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from: app-builtin-zookeeper.yml
+services:
+ zookeeper:
+ image: zookeeper:latest
-props:
- project_name: dubbo-samples-mybatis
- main_class: org.apache.dubbo.samples.boundary.mybatis.MybatisProvider
- zookeeper_port: 2181
- dubbo_port: 20880
+ dubbo-samples-spring-boot-mybatis-provider:
+ type: app
+ basedir: dubbo-samples-spring-boot-mybatis-provider
+ mainClass: org.apache.dubbo.springboot.mybatis.samples.MybatisProviderApplication
+ systemProps:
+ - zookeeper.address=zookeeper
+ waitPortsBeforeRun:
+ - zookeeper:2181
+ checkPorts:
+ - 20880
+ checkLog: "dubbo service started"
+ depends_on:
+ - zookeeper
+
+ dubbo-samples-spring-boot-mybatis-consumer:
+ type: test
+ basedir: dubbo-samples-spring-boot-mybatis-consumer
+ tests:
+ - "**/*IT.class"
+ systemProps:
+ - zookeeper.address=zookeeper
+ waitPortsBeforeRun:
+ - zookeeper:2181
+ - dubbo-samples-spring-boot-mybatis-provider:20880
+ depends_on:
+ - zookeeper
+ - dubbo-samples-spring-boot-mybatis-provider
diff --git a/99-integration/dubbo-samples-mybatis/case-versions.conf b/99-integration/dubbo-samples-mybatis/case-versions.conf
index ec7136bb..32a2e5be 100644
--- a/99-integration/dubbo-samples-mybatis/case-versions.conf
+++ b/99-integration/dubbo-samples-mybatis/case-versions.conf
@@ -19,8 +19,7 @@
# Supported component versions of the test case
-# Spring app
-#dubbo.version=2.7.*, 3.*
-dubbo.version=4.*
+# SpringBoot app
+dubbo.version=2.7*, 3.1*
spring-boot.version=2.*
java.version= [<= 11]
diff --git a/99-integration/dubbo-samples-mybatis/src/main/resources/mapper/UserMapper.xml b/99-integration/dubbo-samples-mybatis/dubbo-samples-spring-boot-mybatis-api/pom.xml
similarity index 53%
copy from 99-integration/dubbo-samples-mybatis/src/main/resources/mapper/UserMapper.xml
copy to 99-integration/dubbo-samples-mybatis/dubbo-samples-spring-boot-mybatis-api/pom.xml
index ba193d05..cb620911 100644
--- a/99-integration/dubbo-samples-mybatis/src/main/resources/mapper/UserMapper.xml
+++ b/99-integration/dubbo-samples-mybatis/dubbo-samples-spring-boot-mybatis-api/pom.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
@@ -15,17 +15,21 @@
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.dubbo.samples.boundary.mybatis.impl.dao.UserDao">
+<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>dubbo-samples-mybatis</artifactId>
+ <groupId>org.apache.dubbo</groupId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
- <resultMap id="BASE_RESULT" type="org.apache.dubbo.samples.boundary.mybatis.impl.dao.UserModel">
- <id column="id" property="id"/>
- <result column="name" property="name"/>
- </resultMap>
- <select id="findByUserId" resultMap="BASE_RESULT">
- SELECT id, name
- FROM user
- where id = #{userId}
- </select>
+ <artifactId>dubbo-samples-spring-boot-mybatis-api</artifactId>
-</mapper>
+ <properties>
+ <maven.compiler.source>8</maven.compiler.source>
+ <maven.compiler.target>8</maven.compiler.target>
+ </properties>
+
+</project>
\ No newline at end of file
diff --git a/99-integration/dubbo-samples-mybatis/src/main/java/org/apache/dubbo/samples/boundary/mybatis/api/MybatisService.java b/99-integration/dubbo-samples-mybatis/dubbo-samples-spring-boot-mybatis-api/src/main/java/org/apache/dubbo/springboot/mybatis/samples/MybatisService.java
similarity index 90%
rename from 99-integration/dubbo-samples-mybatis/src/main/java/org/apache/dubbo/samples/boundary/mybatis/api/MybatisService.java
rename to 99-integration/dubbo-samples-mybatis/dubbo-samples-spring-boot-mybatis-api/src/main/java/org/apache/dubbo/springboot/mybatis/samples/MybatisService.java
index 02c43e98..a3e95b15 100644
--- a/99-integration/dubbo-samples-mybatis/src/main/java/org/apache/dubbo/samples/boundary/mybatis/api/MybatisService.java
+++ b/99-integration/dubbo-samples-mybatis/dubbo-samples-spring-boot-mybatis-api/src/main/java/org/apache/dubbo/springboot/mybatis/samples/MybatisService.java
@@ -17,9 +17,9 @@
*
*/
-package org.apache.dubbo.samples.boundary.mybatis.api;
+package org.apache.dubbo.springboot.mybatis.samples;
public interface MybatisService {
- User findByUserId(long id);
+ User findByUserId(Long id);
}
diff --git a/99-integration/dubbo-samples-mybatis/src/main/java/org/apache/dubbo/samples/boundary/mybatis/api/User.java b/99-integration/dubbo-samples-mybatis/dubbo-samples-spring-boot-mybatis-api/src/main/java/org/apache/dubbo/springboot/mybatis/samples/User.java
similarity index 94%
rename from 99-integration/dubbo-samples-mybatis/src/main/java/org/apache/dubbo/samples/boundary/mybatis/api/User.java
rename to 99-integration/dubbo-samples-mybatis/dubbo-samples-spring-boot-mybatis-api/src/main/java/org/apache/dubbo/springboot/mybatis/samples/User.java
index 75df5d9f..307b761f 100644
--- a/99-integration/dubbo-samples-mybatis/src/main/java/org/apache/dubbo/samples/boundary/mybatis/api/User.java
+++ b/99-integration/dubbo-samples-mybatis/dubbo-samples-spring-boot-mybatis-api/src/main/java/org/apache/dubbo/springboot/mybatis/samples/User.java
@@ -17,7 +17,7 @@
*
*/
-package org.apache.dubbo.samples.boundary.mybatis.api;
+package org.apache.dubbo.springboot.mybatis.samples;
import lombok.Data;
diff --git a/99-integration/dubbo-samples-mybatis/dubbo-samples-spring-boot-mybatis-consumer/pom.xml b/99-integration/dubbo-samples-mybatis/dubbo-samples-spring-boot-mybatis-consumer/pom.xml
new file mode 100644
index 00000000..35f9ab6f
--- /dev/null
+++ b/99-integration/dubbo-samples-mybatis/dubbo-samples-spring-boot-mybatis-consumer/pom.xml
@@ -0,0 +1,48 @@
+<?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>dubbo-samples-mybatis</artifactId>
+ <groupId>org.apache.dubbo</groupId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>dubbo-samples-spring-boot-mybatis-consumer</artifactId>
+
+ <properties>
+ <maven.compiler.source>8</maven.compiler.source>
+ <maven.compiler.target>8</maven.compiler.target>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-samples-spring-boot-mybatis-api</artifactId>
+ <version>${project.parent.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
diff --git a/99-integration/dubbo-samples-mybatis/src/main/java/org/apache/dubbo/samples/boundary/mybatis/MybatisProvider.java b/99-integration/dubbo-samples-mybatis/dubbo-samples-spring-boot-mybatis-consumer/src/main/java/org/apache/dubbo/springboot/mybatis/samples/MybatisConsumerApplication.java
similarity index 52%
copy from 99-integration/dubbo-samples-mybatis/src/main/java/org/apache/dubbo/samples/boundary/mybatis/MybatisProvider.java
copy to 99-integration/dubbo-samples-mybatis/dubbo-samples-spring-boot-mybatis-consumer/src/main/java/org/apache/dubbo/springboot/mybatis/samples/MybatisConsumerApplication.java
index 73d0f607..4f445947 100644
--- a/99-integration/dubbo-samples-mybatis/src/main/java/org/apache/dubbo/samples/boundary/mybatis/MybatisProvider.java
+++ b/99-integration/dubbo-samples-mybatis/dubbo-samples-spring-boot-mybatis-consumer/src/main/java/org/apache/dubbo/springboot/mybatis/samples/MybatisConsumerApplication.java
@@ -17,30 +17,36 @@
*
*/
-package org.apache.dubbo.samples.boundary.mybatis;
+package org.apache.dubbo.springboot.mybatis.samples;
+import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
-
-import org.mybatis.spring.annotation.MapperScan;
-import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.context.annotation.PropertySource;
+import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.stereotype.Service;
-@SpringBootApplication
+@Service
@EnableDubbo
-@MapperScan("org.apache.dubbo.samples.boundary.mybatis")
-@PropertySource("classpath:spring/application-provider.properties")
-public class MybatisProvider implements CommandLineRunner {
+@SpringBootApplication(exclude={DataSourceAutoConfiguration.class})
+public class MybatisConsumerApplication {
- public static void main(String[] args) throws Exception {
- new EmbeddedZooKeeper(2181, false).start();
+ @DubboReference(version = "1.0.0")
+ private MybatisService mybatisService;
- SpringApplication.run(MybatisProvider.class, args);
+ public static void main(String[] args) {
+ ConfigurableApplicationContext context = SpringApplication.run(MybatisConsumerApplication.class, args);
+ MybatisConsumerApplication application = context.getBean(MybatisConsumerApplication.class);
+ User user = application.findByUserId(1L);
+ System.out.println("result: " + user);
}
- @Override
- public void run(String... args) throws Exception {
- System.out.println("dubbo service started");
+ public User findByUserId(Long userId) {
+ return mybatisService.findByUserId(userId);
}
}
+
+
+
+
diff --git a/99-integration/dubbo-samples-hibernate/case-configuration.yml b/99-integration/dubbo-samples-mybatis/dubbo-samples-spring-boot-mybatis-consumer/src/main/resources/application.yml
similarity index 67%
copy from 99-integration/dubbo-samples-hibernate/case-configuration.yml
copy to 99-integration/dubbo-samples-mybatis/dubbo-samples-spring-boot-mybatis-consumer/src/main/resources/application.yml
index 821c36f1..6ecfe9f1 100644
--- a/99-integration/dubbo-samples-hibernate/case-configuration.yml
+++ b/99-integration/dubbo-samples-mybatis/dubbo-samples-spring-boot-mybatis-consumer/src/main/resources/application.yml
@@ -14,11 +14,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from: app-builtin-zookeeper.yml
-
-props:
- project_name: dubbo-samples-hibernate
- main_class: org.apache.dubbo.samples.boundary.hibernate.HibernateProvider
- zookeeper_port: 2181
- dubbo_port: 20880
-
+dubbo:
+ application:
+ name: dubbo-samples-spring-boot-mybatis-consumer
+ protocol:
+ name: dubbo
+ port: 20081
+ registry:
+ id: zk-registry
+ address: zookeeper://${zookeeper.address:127.0.0.1}:2181
+ config-center:
+ address: zookeeper://${zookeeper.address:127.0.0.1}:2181
+ metadata-report:
+ address: zookeeper://${zookeeper.address:127.0.0.1}:2181
diff --git a/99-integration/dubbo-samples-mybatis/dubbo-samples-spring-boot-mybatis-consumer/src/main/resources/log4j.properties b/99-integration/dubbo-samples-mybatis/dubbo-samples-spring-boot-mybatis-consumer/src/main/resources/log4j.properties
new file mode 100644
index 00000000..8de4c4fd
--- /dev/null
+++ b/99-integration/dubbo-samples-mybatis/dubbo-samples-spring-boot-mybatis-consumer/src/main/resources/log4j.properties
@@ -0,0 +1,7 @@
+###set log levels###
+log4j.rootLogger=info, stdout
+###output to the console###
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.Target=System.out
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=[%d{dd/MM/yy HH:mm:ss:SSS z}] %t %5p %c{2}: %m%n
diff --git a/99-integration/dubbo-samples-mybatis/dubbo-samples-spring-boot-mybatis-consumer/src/test/java/org/apache/dubbo/springboot/mybatis/samples/MybatisIT.java b/99-integration/dubbo-samples-mybatis/dubbo-samples-spring-boot-mybatis-consumer/src/test/java/org/apache/dubbo/springboot/mybatis/samples/MybatisIT.java
new file mode 100644
index 00000000..48e75119
--- /dev/null
+++ b/99-integration/dubbo-samples-mybatis/dubbo-samples-spring-boot-mybatis-consumer/src/test/java/org/apache/dubbo/springboot/mybatis/samples/MybatisIT.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.dubbo.springboot.mybatis.samples;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = {MybatisConsumerApplication.class})
+public class MybatisIT {
+ @Autowired
+ private MybatisConsumerApplication consumerApplication;
+
+ @Test
+ public void test() throws Exception {
+ User user = consumerApplication.findByUserId(1L);
+ Assert.assertEquals(1, user.getId());
+ }
+}
diff --git a/99-integration/dubbo-samples-mybatis/dubbo-samples-spring-boot-mybatis-provider/pom.xml b/99-integration/dubbo-samples-mybatis/dubbo-samples-spring-boot-mybatis-provider/pom.xml
new file mode 100644
index 00000000..edab0853
--- /dev/null
+++ b/99-integration/dubbo-samples-mybatis/dubbo-samples-spring-boot-mybatis-provider/pom.xml
@@ -0,0 +1,67 @@
+<?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>dubbo-samples-mybatis</artifactId>
+ <groupId>org.apache.dubbo</groupId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>dubbo-samples-spring-boot-mybatis-provider</artifactId>
+
+ <properties>
+ <maven.compiler.source>8</maven.compiler.source>
+ <maven.compiler.target>8</maven.compiler.target>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-samples-spring-boot-mybatis-api</artifactId>
+ <version>${project.parent.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <version>1.4.200</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.alibaba</groupId>
+ <artifactId>druid</artifactId>
+ <version>1.2.6</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.liquibase</groupId>
+ <artifactId>liquibase-core</artifactId>
+ <version>4.4.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.baomidou</groupId>
+ <artifactId>mybatis-plus-boot-starter</artifactId>
+ <version>${mybatis-plus-starter.version}</version>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
diff --git a/99-integration/dubbo-samples-hibernate/src/main/java/org/apache/dubbo/samples/boundary/hibernate/EmbeddedZooKeeper.java b/99-integration/dubbo-samples-mybatis/dubbo-samples-spring-boot-mybatis-provider/src/main/java/org/apache/dubbo/springboot/mybatis/samples/EmbeddedZooKeeper.java
similarity index 99%
rename from 99-integration/dubbo-samples-hibernate/src/main/java/org/apache/dubbo/samples/boundary/hibernate/EmbeddedZooKeeper.java
rename to 99-integration/dubbo-samples-mybatis/dubbo-samples-spring-boot-mybatis-provider/src/main/java/org/apache/dubbo/springboot/mybatis/samples/EmbeddedZooKeeper.java
index be37d35c..1549412c 100644
--- a/99-integration/dubbo-samples-hibernate/src/main/java/org/apache/dubbo/samples/boundary/hibernate/EmbeddedZooKeeper.java
+++ b/99-integration/dubbo-samples-mybatis/dubbo-samples-spring-boot-mybatis-provider/src/main/java/org/apache/dubbo/springboot/mybatis/samples/EmbeddedZooKeeper.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.samples.boundary.hibernate;
+package org.apache.dubbo.springboot.mybatis.samples;
import org.apache.zookeeper.server.ServerConfig;
import org.apache.zookeeper.server.ZooKeeperServerMain;
diff --git a/99-integration/dubbo-samples-mybatis/src/main/java/org/apache/dubbo/samples/boundary/mybatis/MybatisProvider.java b/99-integration/dubbo-samples-mybatis/dubbo-samples-spring-boot-mybatis-provider/src/main/java/org/apache/dubbo/springboot/mybatis/samples/MybatisProviderApplication.java
similarity index 72%
rename from 99-integration/dubbo-samples-mybatis/src/main/java/org/apache/dubbo/samples/boundary/mybatis/MybatisProvider.java
rename to 99-integration/dubbo-samples-mybatis/dubbo-samples-spring-boot-mybatis-provider/src/main/java/org/apache/dubbo/springboot/mybatis/samples/MybatisProviderApplication.java
index 73d0f607..5d8181e8 100644
--- a/99-integration/dubbo-samples-mybatis/src/main/java/org/apache/dubbo/samples/boundary/mybatis/MybatisProvider.java
+++ b/99-integration/dubbo-samples-mybatis/dubbo-samples-spring-boot-mybatis-provider/src/main/java/org/apache/dubbo/springboot/mybatis/samples/MybatisProviderApplication.java
@@ -17,30 +17,24 @@
*
*/
-package org.apache.dubbo.samples.boundary.mybatis;
+package org.apache.dubbo.springboot.mybatis.samples;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
-
import org.mybatis.spring.annotation.MapperScan;
-import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.context.annotation.PropertySource;
@SpringBootApplication
@EnableDubbo
-@MapperScan("org.apache.dubbo.samples.boundary.mybatis")
-@PropertySource("classpath:spring/application-provider.properties")
-public class MybatisProvider implements CommandLineRunner {
+@MapperScan("org.apache.dubbo.springboot.mybatis.samples.dao")
+public class MybatisProviderApplication {
public static void main(String[] args) throws Exception {
new EmbeddedZooKeeper(2181, false).start();
- SpringApplication.run(MybatisProvider.class, args);
- }
+ SpringApplication.run(MybatisProviderApplication.class, args);
- @Override
- public void run(String... args) throws Exception {
System.out.println("dubbo service started");
+
}
}
diff --git a/99-integration/dubbo-samples-mybatis/src/main/java/org/apache/dubbo/samples/boundary/mybatis/impl/dao/UserDao.java b/99-integration/dubbo-samples-mybatis/dubbo-samples-spring-boot-mybatis-provider/src/main/java/org/apache/dubbo/springboot/mybatis/samples/dao/UserDao.java
similarity index 89%
rename from 99-integration/dubbo-samples-mybatis/src/main/java/org/apache/dubbo/samples/boundary/mybatis/impl/dao/UserDao.java
rename to 99-integration/dubbo-samples-mybatis/dubbo-samples-spring-boot-mybatis-provider/src/main/java/org/apache/dubbo/springboot/mybatis/samples/dao/UserDao.java
index 2afe665f..2a09db2d 100644
--- a/99-integration/dubbo-samples-mybatis/src/main/java/org/apache/dubbo/samples/boundary/mybatis/impl/dao/UserDao.java
+++ b/99-integration/dubbo-samples-mybatis/dubbo-samples-spring-boot-mybatis-provider/src/main/java/org/apache/dubbo/springboot/mybatis/samples/dao/UserDao.java
@@ -17,7 +17,7 @@
*
*/
-package org.apache.dubbo.samples.boundary.mybatis.impl.dao;
+package org.apache.dubbo.springboot.mybatis.samples.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
@@ -27,5 +27,5 @@ import org.springframework.stereotype.Repository;
@Mapper
@Repository
public interface UserDao extends BaseMapper<UserModel> {
- public UserModel findByUserId(@Param("userId") long userId);
+ UserModel findByUserId(@Param("userId") long userId);
}
diff --git a/99-integration/dubbo-samples-mybatis/src/main/java/org/apache/dubbo/samples/boundary/mybatis/impl/dao/UserModel.java b/99-integration/dubbo-samples-mybatis/dubbo-samples-spring-boot-mybatis-provider/src/main/java/org/apache/dubbo/springboot/mybatis/samples/dao/UserModel.java
similarity index 91%
rename from 99-integration/dubbo-samples-mybatis/src/main/java/org/apache/dubbo/samples/boundary/mybatis/impl/dao/UserModel.java
rename to 99-integration/dubbo-samples-mybatis/dubbo-samples-spring-boot-mybatis-provider/src/main/java/org/apache/dubbo/springboot/mybatis/samples/dao/UserModel.java
index f191d7d0..d33952cb 100644
--- a/99-integration/dubbo-samples-mybatis/src/main/java/org/apache/dubbo/samples/boundary/mybatis/impl/dao/UserModel.java
+++ b/99-integration/dubbo-samples-mybatis/dubbo-samples-spring-boot-mybatis-provider/src/main/java/org/apache/dubbo/springboot/mybatis/samples/dao/UserModel.java
@@ -17,12 +17,12 @@
*
*/
-package org.apache.dubbo.samples.boundary.mybatis.impl.dao;
+package org.apache.dubbo.springboot.mybatis.samples.dao;
import lombok.Data;
@Data
public class UserModel {
- private long id;
+ private Long id;
private String name;
}
diff --git a/99-integration/dubbo-samples-mybatis/src/main/java/org/apache/dubbo/samples/boundary/mybatis/impl/MybatisServiceImpl.java b/99-integration/dubbo-samples-mybatis/dubbo-samples-spring-boot-mybatis-provider/src/main/java/org/apache/dubbo/springboot/mybatis/samples/impl/MybatisServiceImpl.java
similarity index 71%
rename from 99-integration/dubbo-samples-mybatis/src/main/java/org/apache/dubbo/samples/boundary/mybatis/impl/MybatisServiceImpl.java
rename to 99-integration/dubbo-samples-mybatis/dubbo-samples-spring-boot-mybatis-provider/src/main/java/org/apache/dubbo/springboot/mybatis/samples/impl/MybatisServiceImpl.java
index 21e23713..482ad46b 100644
--- a/99-integration/dubbo-samples-mybatis/src/main/java/org/apache/dubbo/samples/boundary/mybatis/impl/MybatisServiceImpl.java
+++ b/99-integration/dubbo-samples-mybatis/dubbo-samples-spring-boot-mybatis-provider/src/main/java/org/apache/dubbo/springboot/mybatis/samples/impl/MybatisServiceImpl.java
@@ -16,14 +16,13 @@
* limitations under the License.
*
*/
-package org.apache.dubbo.samples.boundary.mybatis.impl;
+package org.apache.dubbo.springboot.mybatis.samples.impl;
import org.apache.dubbo.config.annotation.DubboService;
-import org.apache.dubbo.samples.boundary.mybatis.api.MybatisService;
-import org.apache.dubbo.samples.boundary.mybatis.api.User;
-import org.apache.dubbo.samples.boundary.mybatis.impl.dao.UserDao;
-import org.apache.dubbo.samples.boundary.mybatis.impl.dao.UserModel;
-
+import org.apache.dubbo.springboot.mybatis.samples.MybatisService;
+import org.apache.dubbo.springboot.mybatis.samples.User;
+import org.apache.dubbo.springboot.mybatis.samples.dao.UserDao;
+import org.apache.dubbo.springboot.mybatis.samples.dao.UserModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -35,14 +34,11 @@ public class MybatisServiceImpl implements MybatisService {
private UserDao userDao;
@Override
- public User findByUserId(long id) {
+ public User findByUserId(Long id) {
UserModel userModel = userDao.findByUserId(id);
-
- User u = new User();
-
- u.setId(userModel.getId());
- u.setName(userModel.getName());
-
- return u;
+ User user = new User();
+ user.setId(userModel.getId());
+ user.setName(userModel.getName());
+ return user;
}
}
diff --git a/99-integration/dubbo-samples-hibernate/case-configuration.yml b/99-integration/dubbo-samples-mybatis/dubbo-samples-spring-boot-mybatis-provider/src/main/resources/application.yml
similarity index 52%
copy from 99-integration/dubbo-samples-hibernate/case-configuration.yml
copy to 99-integration/dubbo-samples-mybatis/dubbo-samples-spring-boot-mybatis-provider/src/main/resources/application.yml
index 821c36f1..8a30505d 100644
--- a/99-integration/dubbo-samples-hibernate/case-configuration.yml
+++ b/99-integration/dubbo-samples-mybatis/dubbo-samples-spring-boot-mybatis-provider/src/main/resources/application.yml
@@ -14,11 +14,26 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from: app-builtin-zookeeper.yml
-
-props:
- project_name: dubbo-samples-hibernate
- main_class: org.apache.dubbo.samples.boundary.hibernate.HibernateProvider
- zookeeper_port: 2181
- dubbo_port: 20880
+dubbo:
+ application:
+ name: dubbo-samples-spring-boot-mybatis-provider
+ protocol:
+ name: dubbo
+ port: 20880
+ registry:
+ id: zk-registry
+ address: zookeeper://${zookeeper.address:127.0.0.1}:2181
+ config-center:
+ address: zookeeper://${zookeeper.address:127.0.0.1}:2181
+ metadata-report:
+ address: zookeeper://${zookeeper.address:127.0.0.1}:2181
+ scan:
+ base-packages: org.apache.dubbo.springboot.mybatis.samples
+spring:
+ liquibase:
+ change-log: liquibase/liquibase-changelog.xml
+ datasource:
+ type: com.alibaba.druid.pool.DruidDataSource
+ driver-class-name: org.h2.Driver
+ url: jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1;MODE=Oracle;TRACE_LEVEL_SYSTEM_OUT=2;DATABASE_TO_LOWER=TRUE
diff --git a/99-integration/dubbo-samples-hibernate/src/main/resources/liquibase/liquibase-changelog.xml b/99-integration/dubbo-samples-mybatis/dubbo-samples-spring-boot-mybatis-provider/src/main/resources/liquibase/liquibase-changelog.xml
similarity index 100%
rename from 99-integration/dubbo-samples-hibernate/src/main/resources/liquibase/liquibase-changelog.xml
rename to 99-integration/dubbo-samples-mybatis/dubbo-samples-spring-boot-mybatis-provider/src/main/resources/liquibase/liquibase-changelog.xml
diff --git a/99-integration/dubbo-samples-mybatis/dubbo-samples-spring-boot-mybatis-provider/src/main/resources/log4j.properties b/99-integration/dubbo-samples-mybatis/dubbo-samples-spring-boot-mybatis-provider/src/main/resources/log4j.properties
new file mode 100644
index 00000000..8de4c4fd
--- /dev/null
+++ b/99-integration/dubbo-samples-mybatis/dubbo-samples-spring-boot-mybatis-provider/src/main/resources/log4j.properties
@@ -0,0 +1,7 @@
+###set log levels###
+log4j.rootLogger=info, stdout
+###output to the console###
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.Target=System.out
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=[%d{dd/MM/yy HH:mm:ss:SSS z}] %t %5p %c{2}: %m%n
diff --git a/99-integration/dubbo-samples-mybatis/src/main/resources/mapper/UserMapper.xml b/99-integration/dubbo-samples-mybatis/dubbo-samples-spring-boot-mybatis-provider/src/main/resources/mapper/UserMapper.xml
similarity index 86%
rename from 99-integration/dubbo-samples-mybatis/src/main/resources/mapper/UserMapper.xml
rename to 99-integration/dubbo-samples-mybatis/dubbo-samples-spring-boot-mybatis-provider/src/main/resources/mapper/UserMapper.xml
index ba193d05..fa793701 100644
--- a/99-integration/dubbo-samples-mybatis/src/main/resources/mapper/UserMapper.xml
+++ b/99-integration/dubbo-samples-mybatis/dubbo-samples-spring-boot-mybatis-provider/src/main/resources/mapper/UserMapper.xml
@@ -16,9 +16,9 @@
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.dubbo.samples.boundary.mybatis.impl.dao.UserDao">
+<mapper namespace="org.apache.dubbo.springboot.mybatis.samples.dao.UserDao">
- <resultMap id="BASE_RESULT" type="org.apache.dubbo.samples.boundary.mybatis.impl.dao.UserModel">
+ <resultMap id="BASE_RESULT" type="org.apache.dubbo.springboot.mybatis.samples.dao.UserModel">
<id column="id" property="id"/>
<result column="name" property="name"/>
</resultMap>
diff --git a/99-integration/dubbo-samples-mybatis/pom.xml b/99-integration/dubbo-samples-mybatis/pom.xml
index d62c3d67..f6545057 100644
--- a/99-integration/dubbo-samples-mybatis/pom.xml
+++ b/99-integration/dubbo-samples-mybatis/pom.xml
@@ -19,6 +19,11 @@
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
+ <modules>
+ <module>dubbo-samples-spring-boot-mybatis-api</module>
+ <module>dubbo-samples-spring-boot-mybatis-provider</module>
+ <module>dubbo-samples-spring-boot-mybatis-consumer</module>
+ </modules>
<parent>
<groupId>org.apache</groupId>
<artifactId>apache</artifactId>
@@ -31,6 +36,7 @@
<version>1.0-SNAPSHOT</version>
<name>Dubbo Samples Mybatis</name>
<description>Dubbo Samples Mybatis</description>
+ <packaging>pom</packaging>
<properties>
<source.level>1.8</source.level>
@@ -73,36 +79,12 @@
<artifactId>spring-boot-starter</artifactId>
</dependency>
- <dependency>
- <groupId>com.baomidou</groupId>
- <artifactId>mybatis-plus-boot-starter</artifactId>
- <version>${mybatis-plus-starter.version}</version>
- </dependency>
-
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
<version>${dubbo.version}</version>
</dependency>
- <dependency>
- <groupId>com.h2database</groupId>
- <artifactId>h2</artifactId>
- <version>1.4.200</version>
- </dependency>
-
- <dependency>
- <groupId>com.alibaba</groupId>
- <artifactId>druid</artifactId>
- <version>1.2.6</version>
- </dependency>
-
- <dependency>
- <groupId>org.liquibase</groupId>
- <artifactId>liquibase-core</artifactId>
- <version>4.4.0</version>
- </dependency>
-
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-dependencies-zookeeper</artifactId>
diff --git a/99-integration/dubbo-samples-mybatis/src/main/java/org/apache/dubbo/samples/boundary/mybatis/MybatisConsumer.java b/99-integration/dubbo-samples-mybatis/src/main/java/org/apache/dubbo/samples/boundary/mybatis/MybatisConsumer.java
deleted file mode 100644
index 7fbbceca..00000000
--- a/99-integration/dubbo-samples-mybatis/src/main/java/org/apache/dubbo/samples/boundary/mybatis/MybatisConsumer.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- *
- * 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.dubbo.samples.boundary.mybatis;
-
-import org.apache.dubbo.samples.boundary.mybatis.api.MybatisService;
-import org.apache.dubbo.samples.boundary.mybatis.api.User;
-
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-public class MybatisConsumer {
-
- public static void main(String[] args) throws Exception {
- ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/hibernate-consumer.xml");
- context.start();
-
- MybatisService mybatisService = (MybatisService) context.getBean(MybatisService.class);
-
- for (int i = 0; i < 5; i++) {
- User user = mybatisService.findByUserId(1L);
- System.out.println("find user: " + user);
- }
- }
-}
diff --git a/99-integration/dubbo-samples-mybatis/src/main/resources/log4j.properties b/99-integration/dubbo-samples-mybatis/src/main/resources/log4j.properties
deleted file mode 100644
index d6ecd5ce..00000000
--- a/99-integration/dubbo-samples-mybatis/src/main/resources/log4j.properties
+++ /dev/null
@@ -1,26 +0,0 @@
-#
-#
-# 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.
-#
-#
-
-###set log levels###
-log4j.rootLogger=info, stdout
-###output to the console###
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.Target=System.out
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=[%d{dd/MM/yy hh:mm:ss:sss z}] %t %5p %c{2}: %m%n
\ No newline at end of file
diff --git a/99-integration/dubbo-samples-mybatis/src/main/resources/spring/application-provider.properties b/99-integration/dubbo-samples-mybatis/src/main/resources/spring/application-provider.properties
deleted file mode 100644
index 16484a3b..00000000
--- a/99-integration/dubbo-samples-mybatis/src/main/resources/spring/application-provider.properties
+++ /dev/null
@@ -1,12 +0,0 @@
-spring.liquibase.change-log=classpath:liquibase/liquibase-changelog.xml
-spring.application.name=mybatis-provider
-dubbo.scan.base-packages=org.apache.dubbo.samples.boundary.mybatis
-dubbo.protocol.name=dubbo
-dubbo.protocol.port=20880
-dubbo.registry.address=zookeeper://127.0.0.1:2181
-dubbo.provider.token=true
-dubbo.application.name=${spring.application.name}
-
-spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
-spring.datasource.driver=org.h2.Driver
-spring.datasource.url=jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1;MODE=Oracle;TRACE_LEVEL_SYSTEM_OUT=2
diff --git a/99-integration/dubbo-samples-mybatis/src/main/resources/spring/mybatis-consumer.xml b/99-integration/dubbo-samples-mybatis/src/main/resources/spring/mybatis-consumer.xml
deleted file mode 100644
index 3501b636..00000000
--- a/99-integration/dubbo-samples-mybatis/src/main/resources/spring/mybatis-consumer.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?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.
- -->
-
-<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:dubbo="http://dubbo.apache.org/schema/dubbo"
- xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
- http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
- <context:property-placeholder/>
-
- <dubbo:application name="mybatis-consumer"/>
-
- <dubbo:registry address="zookeeper://${zookeeper.address:127.0.0.1}:${zookeeper.port:2181}"/>
-
- <dubbo:reference id="cacheService" interface="org.apache.dubbo.samples.boundary.mybatis.api.MybatisService"
- version="1.0.0"/>
-
-</beans>
diff --git a/99-integration/dubbo-samples-mybatis/src/test/java/org/apache/dubbo/samples/boundary/mybatis/MybatisServiceIT.java b/99-integration/dubbo-samples-mybatis/src/test/java/org/apache/dubbo/samples/boundary/mybatis/MybatisServiceIT.java
deleted file mode 100644
index da35f79d..00000000
--- a/99-integration/dubbo-samples-mybatis/src/test/java/org/apache/dubbo/samples/boundary/mybatis/MybatisServiceIT.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * 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.
- */
-
-/*
- * Copyright 2014 the original author or authors.
- *
- * Licensed 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.dubbo.samples.boundary.mybatis;
-
-import org.apache.dubbo.samples.boundary.mybatis.api.MybatisService;
-import org.apache.dubbo.samples.boundary.mybatis.api.User;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.not;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.core.IsNull.nullValue;
-
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations = "classpath*:spring/mybatis-consumer.xml")
-public class MybatisServiceIT {
- @Autowired
- private MybatisService service;
-
- @Test
- public void shouldGetDataFromMybatis() throws Exception {
- User user = service.findByUserId(1);
-
- assertThat(user, not(nullValue()));
- assertThat(user.getName(), is("apache dubbo"));
- }
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org