You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by me...@apache.org on 2019/01/08 07:56:26 UTC
[incubator-dubbo-spring-boot-project] branch 0.1.x updated: 0.1.x
(#364)
This is an automated email from the ASF dual-hosted git repository.
mercyblitz pushed a commit to branch 0.1.x
in repository https://gitbox.apache.org/repos/asf/incubator-dubbo-spring-boot-project.git
The following commit(s) were added to refs/heads/0.1.x by this push:
new e99a9f5 0.1.x (#364)
e99a9f5 is described below
commit e99a9f522088d987b52f28cb42555044bf92f75a
Author: 小马哥 <me...@gmail.com>
AuthorDate: Tue Jan 8 15:56:22 2019 +0800
0.1.x (#364)
* Bug fix on test case
* Polish apache/incubator-dubbo-spring-boot-project#327 & apache/incubator-dubbo-spring-boot-project#325
* Polish apache/incubator-dubbo-spring-boot-project#321
* Polish apache/incubator-dubbo-spring-boot-project#220 no program
* Switch Yaml file
* Update version to be 0.2.0
* Polish apache/incubator-dubbo-spring-boot-project#218
* Update Documents
* Fix the test case's bugs
* Fix plugins' issues
* Fix test-cases
* Fix test cases
* Fixes an issue on DubboMvcEndpoint
* Polish: Fix a relaxed property name issue
* Optimize Awaiting implementation
* Remove author from JavaDoc
* Refactor
* Merge
* Update dependencies and implementations
* Update Samples
* Fix the test cases
---
dubbo-spring-boot-autoconfigure/pom.xml | 3 +-
...oDefaultPropertiesEnvironmentPostProcessor.java | 20 ++
...DubboAutoConfigurationOnMultipleConfigTest.java | 5 +-
.../DubboAutoConfigurationOnSingleConfigTest.java | 4 +-
...aultPropertiesEnvironmentPostProcessorTest.java | 18 +-
dubbo-spring-boot-parent/pom.xml | 69 ++----
.../consumer-sample}/pom.xml | 24 +-
.../DubboAutoConfigurationConsumerBootstrap.java | 56 +++++
.../src/main/resources/application.yml | 3 +
.../pom.xml | 19 +-
.../provider-sample}/pom.xml | 25 +-
.../DubboAutoConfigurationProviderBootstrap.java} | 11 +-
.../demo/provider/service/DefaultDemoService.java | 17 +-
.../src/main/resources/application.properties | 12 +
.../consumer-sample}/pom.xml | 41 ++--
.../DubboRegistryNacosConsumerBootstrap.java | 54 +++++
.../src/main/resources/application.yml | 11 +
.../pom.xml | 19 +-
.../provider-sample}/pom.xml | 39 ++--
.../DubboRegistryNacosProviderBootstrap.java} | 13 +-
.../demo/provider/service/DefaultDemoService.java} | 32 ++-
.../src/main/resources/application.properties | 20 ++
.../consumer-sample}/pom.xml | 29 ++-
.../DubboRegistryZooKeeperConsumerBootstrap.java | 54 +++++
.../src/main/resources/application.yml | 15 ++
.../pom.xml | 19 +-
.../provider-sample}/pom.xml | 32 +--
.../DubboRegistryZooKeeperProviderBootstrap.java} | 24 +-
.../demo/provider/bootstrap/EmbeddedZooKeeper.java | 252 +++++++++++++++++++++
.../demo/provider/service/DefaultDemoService.java | 17 +-
.../src/main/resources/application.properties | 22 ++
.../src/main/resources/application.yml | 31 ---
.../src/main/resources/application-prod.properties | 9 -
.../src/main/resources/application.properties | 25 --
.../consumer-sample}/pom.xml | 24 +-
...ExternalizedConfigurationConsumerBootstrap.java | 54 +++++
.../src/main/resources/application.yml | 8 +
.../pom.xml | 16 +-
.../provider-sample}/pom.xml | 22 +-
...xternalizedConfigurationProviderBootstrap.java} | 18 +-
.../demo/provider/service/DefaultDemoService.java | 17 +-
.../src/main/resources/application.properties | 19 ++
dubbo-spring-boot-samples/pom.xml | 10 +-
.../pom.xml | 6 +-
.../boot/dubbo/demo/consumer/DemoService.java | 0
45 files changed, 901 insertions(+), 337 deletions(-)
diff --git a/dubbo-spring-boot-autoconfigure/pom.xml b/dubbo-spring-boot-autoconfigure/pom.xml
index a878a65..26097bb 100644
--- a/dubbo-spring-boot-autoconfigure/pom.xml
+++ b/dubbo-spring-boot-autoconfigure/pom.xml
@@ -20,9 +20,8 @@
<parent>
<groupId>com.alibaba.boot</groupId>
<artifactId>dubbo-spring-boot-parent</artifactId>
-
<version>0.1.2-SNAPSHOT</version>
- <relativePath>../dubbo-spring-boot-parent</relativePath>
+ <relativePath>../dubbo-spring-boot-parent/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/env/DubboDefaultPropertiesEnvironmentPostProcessor.java b/dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/env/DubboDefaultPropertiesEnvironmentPostProcessor.java
index d8a671b..3292bf9 100644
--- a/dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/env/DubboDefaultPropertiesEnvironmentPostProcessor.java
+++ b/dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/env/DubboDefaultPropertiesEnvironmentPostProcessor.java
@@ -64,6 +64,16 @@ public class DubboDefaultPropertiesEnvironmentPostProcessor implements Environme
*/
private static final String DUBBO_APPLICATION_NAME_PROPERTY = "dubbo.application.name";
+ /**
+ * The property name of {@link EnableDubboConfig#multiple() @EnableDubboConfig.multiple()}
+ */
+ private static final String DUBBO_CONFIG_MULTIPLE_PROPERTY = "dubbo.config.multiple";
+
+ /**
+ * The property name of {@link ApplicationConfig#getQosEnable() application's QOS enable}
+ */
+ private static final String DUBBO_APPLICATION_QOS_ENABLE_PROPERTY = "dubbo.application.qos-enable";
+
@Override
public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
MutablePropertySources propertySources = environment.getPropertySources();
@@ -81,6 +91,8 @@ public class DubboDefaultPropertiesEnvironmentPostProcessor implements Environme
private Map<String, Object> createDefaultProperties(ConfigurableEnvironment environment) {
Map<String, Object> defaultProperties = new HashMap<String, Object>();
setDubboApplicationNameProperty(environment, defaultProperties);
+ setDubboConfigMultipleProperty(defaultProperties);
+ setDubboApplicationQosEnableProperty(defaultProperties);
return defaultProperties;
}
@@ -92,6 +104,14 @@ public class DubboDefaultPropertiesEnvironmentPostProcessor implements Environme
}
}
+ private void setDubboConfigMultipleProperty(Map<String, Object> defaultProperties) {
+ defaultProperties.put(DUBBO_CONFIG_MULTIPLE_PROPERTY, Boolean.TRUE.toString());
+ }
+
+ private void setDubboApplicationQosEnableProperty(Map<String, Object> defaultProperties) {
+ defaultProperties.put(DUBBO_APPLICATION_QOS_ENABLE_PROPERTY, Boolean.FALSE.toString());
+ }
+
/**
* Copy from BusEnvironmentPostProcessor#addOrReplace(MutablePropertySources, Map)
*
diff --git a/dubbo-spring-boot-autoconfigure/src/test/java/com/alibaba/boot/dubbo/autoconfigure/DubboAutoConfigurationOnMultipleConfigTest.java b/dubbo-spring-boot-autoconfigure/src/test/java/com/alibaba/boot/dubbo/autoconfigure/DubboAutoConfigurationOnMultipleConfigTest.java
index 8360d7f..fbcdabd 100644
--- a/dubbo-spring-boot-autoconfigure/src/test/java/com/alibaba/boot/dubbo/autoconfigure/DubboAutoConfigurationOnMultipleConfigTest.java
+++ b/dubbo-spring-boot-autoconfigure/src/test/java/com/alibaba/boot/dubbo/autoconfigure/DubboAutoConfigurationOnMultipleConfigTest.java
@@ -43,6 +43,7 @@ import static org.springframework.beans.factory.BeanFactoryUtils.beansOfTypeIncl
/**
* {@link DubboAutoConfiguration} Test On multiple Dubbo Configuration
*
+ * @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
* @since 1.0.0
*/
@RunWith(SpringJUnit4ClassRunner.class)
@@ -152,7 +153,7 @@ public class DubboAutoConfigurationOnMultipleConfigTest {
public void testMultipleDubboConfigBindingProperties() {
- Assert.assertEquals(2, applications.size());
+ Assert.assertEquals(3, applications.size());
Assert.assertEquals(1, modules.size());
@@ -176,7 +177,7 @@ public class DubboAutoConfigurationOnMultipleConfigTest {
*/
Map<String, ApplicationConfig> applications = beansOfTypeIncludingAncestors(applicationContext, ApplicationConfig.class);
- Assert.assertEquals(2, applications.size());
+ Assert.assertEquals(3, applications.size());
/**
* Multiple {@link ModuleConfig}
diff --git a/dubbo-spring-boot-autoconfigure/src/test/java/com/alibaba/boot/dubbo/autoconfigure/DubboAutoConfigurationOnSingleConfigTest.java b/dubbo-spring-boot-autoconfigure/src/test/java/com/alibaba/boot/dubbo/autoconfigure/DubboAutoConfigurationOnSingleConfigTest.java
index 013adec..7f4cd5e 100644
--- a/dubbo-spring-boot-autoconfigure/src/test/java/com/alibaba/boot/dubbo/autoconfigure/DubboAutoConfigurationOnSingleConfigTest.java
+++ b/dubbo-spring-boot-autoconfigure/src/test/java/com/alibaba/boot/dubbo/autoconfigure/DubboAutoConfigurationOnSingleConfigTest.java
@@ -150,7 +150,7 @@ public class DubboAutoConfigurationOnSingleConfigTest {
@Test
public void testMultipleDubboConfigConfiguration() {
- Assert.assertNull(multipleDubboConfigConfiguration);
+ Assert.assertNotNull(multipleDubboConfigConfiguration);
}
@Test
@@ -160,7 +160,7 @@ public class DubboAutoConfigurationOnSingleConfigTest {
@Test
public void testServiceAnnotationBeanPostProcessor() {
- Assert.assertNull(multipleDubboConfigConfiguration);
+ Assert.assertNotNull(multipleDubboConfigConfiguration);
}
}
diff --git a/dubbo-spring-boot-autoconfigure/src/test/java/com/alibaba/boot/dubbo/env/DubboDefaultPropertiesEnvironmentPostProcessorTest.java b/dubbo-spring-boot-autoconfigure/src/test/java/com/alibaba/boot/dubbo/env/DubboDefaultPropertiesEnvironmentPostProcessorTest.java
index 626f2c9..d941a4f 100644
--- a/dubbo-spring-boot-autoconfigure/src/test/java/com/alibaba/boot/dubbo/env/DubboDefaultPropertiesEnvironmentPostProcessorTest.java
+++ b/dubbo-spring-boot-autoconfigure/src/test/java/com/alibaba/boot/dubbo/env/DubboDefaultPropertiesEnvironmentPostProcessorTest.java
@@ -51,7 +51,9 @@ public class DubboDefaultPropertiesEnvironmentPostProcessorTest {
MutablePropertySources propertySources = environment.getPropertySources();
// Nothing to change
PropertySource defaultPropertySource = propertySources.get("defaultProperties");
- Assert.assertNull(defaultPropertySource);
+ Assert.assertNotNull(defaultPropertySource);
+ Assert.assertEquals("true", defaultPropertySource.getProperty("dubbo.config.multiple"));
+ Assert.assertEquals("false", defaultPropertySource.getProperty("dubbo.application.qos-enable"));
// Case 2 : Only set property "spring.application.name"
environment.setProperty("spring.application.name", "demo-dubbo-application");
@@ -67,7 +69,7 @@ public class DubboDefaultPropertiesEnvironmentPostProcessorTest {
environment.setProperty("dubbo.application.name", "demo-dubbo-application");
instance.postProcessEnvironment(environment, springApplication);
defaultPropertySource = propertySources.get("defaultProperties");
- Assert.assertNull(defaultPropertySource);
+ Assert.assertNotNull(defaultPropertySource);
dubboApplicationName = environment.getProperty("dubbo.application.name");
Assert.assertEquals("demo-dubbo-application", dubboApplicationName);
@@ -81,5 +83,15 @@ public class DubboDefaultPropertiesEnvironmentPostProcessorTest {
defaultPropertySource = propertySources.get("defaultProperties");
dubboApplicationName = defaultPropertySource.getProperty("dubbo.application.name");
Assert.assertEquals("demo-dubbo-application", dubboApplicationName);
+
+ // Case 5 : Rest dubbo.config.multiple and dubbo.application.qos-enable
+ environment = new MockEnvironment();
+ propertySources = environment.getPropertySources();
+ propertySources.addLast(new MapPropertySource("defaultProperties", new HashMap<String, Object>()));
+ environment.setProperty("dubbo.config.multiple", "false");
+ environment.setProperty("dubbo.application.qos-enable", "true");
+ instance.postProcessEnvironment(environment, springApplication);
+ Assert.assertEquals("false", environment.getProperty("dubbo.config.multiple"));
+ Assert.assertEquals("true", environment.getProperty("dubbo.application.qos-enable"));
}
-}
+}
\ No newline at end of file
diff --git a/dubbo-spring-boot-parent/pom.xml b/dubbo-spring-boot-parent/pom.xml
index dae76a1..5c08dc8 100644
--- a/dubbo-spring-boot-parent/pom.xml
+++ b/dubbo-spring-boot-parent/pom.xml
@@ -39,11 +39,8 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<spring-boot.version>1.5.18.RELEASE</spring-boot.version>
<dubbo.version>2.6.5</dubbo.version>
- <zkclient.version>0.2</zkclient.version>
- <zookeeper.version>3.4.9</zookeeper.version>
- <curator-framework.version>2.12.0</curator-framework.version>
- <alibaba-spring-context-support.version>1.0.2</alibaba-spring-context-support.version>
-
+ <dubbo-registry-nacos.version>0.0.2</dubbo-registry-nacos.version>
+ <nacos-client.version>0.6.2</nacos-client.version>
<!-- Build args -->
<argline>-server -Xms256m -Xmx512m -XX:PermSize=64m -XX:MaxPermSize=128m -Dfile.encoding=UTF-8
-Djava.net.preferIPv4Stack=true
@@ -63,7 +60,6 @@
<dependencyManagement>
<dependencies>
-
<!-- Spring Boot -->
<dependency>
<groupId>org.springframework.boot</groupId>
@@ -73,6 +69,15 @@
<scope>import</scope>
</dependency>
+ <!-- Dubbo dependencies -->
+ <dependency>
+ <groupId>com.alibaba</groupId>
+ <artifactId>dubbo-dependencies-bom</artifactId>
+ <version>${dubbo.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+
<!-- Dubbo -->
<dependency>
<groupId>com.alibaba</groupId>
@@ -94,54 +99,18 @@
</exclusions>
</dependency>
- <!-- Alibaba Spring Context extension -->
- <dependency>
- <groupId>com.alibaba.spring</groupId>
- <artifactId>spring-context-support</artifactId>
- <version>${alibaba-spring-context-support.version}</version>
- </dependency>
-
- <!-- ZK -->
- <dependency>
- <groupId>org.apache.zookeeper</groupId>
- <artifactId>zookeeper</artifactId>
- <version>${zookeeper.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- </exclusion>
- <exclusion>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
+ <!-- Dubbo Nacos registry dependency -->
<dependency>
- <groupId>com.101tec</groupId>
- <artifactId>zkclient</artifactId>
- <version>${zkclient.version}</version>
- <exclusions>
- <exclusion>
- <artifactId>slf4j-api</artifactId>
- <groupId>org.slf4j</groupId>
- </exclusion>
- <exclusion>
- <artifactId>log4j</artifactId>
- <groupId>log4j</groupId>
- </exclusion>
- <exclusion>
- <artifactId>slf4j-log4j12</artifactId>
- <groupId>org.slf4j</groupId>
- </exclusion>
- </exclusions>
+ <groupId>com.alibaba</groupId>
+ <artifactId>dubbo-registry-nacos</artifactId>
+ <version>${dubbo-registry-nacos.version}</version>
</dependency>
+ <!-- Keep latest Nacos client version -->
<dependency>
- <groupId>org.apache.curator</groupId>
- <artifactId>curator-framework</artifactId>
- <version>${curator-framework.version}</version>
+ <groupId>com.alibaba.nacos</groupId>
+ <artifactId>nacos-client</artifactId>
+ <version>${nacos-client.version}</version>
</dependency>
</dependencies>
diff --git a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/pom.xml b/dubbo-spring-boot-samples/auto-configure-samples/consumer-sample/pom.xml
similarity index 79%
copy from dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/pom.xml
copy to dubbo-spring-boot-samples/auto-configure-samples/consumer-sample/pom.xml
index 97365d7..27b9d9c 100644
--- a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/pom.xml
+++ b/dubbo-spring-boot-samples/auto-configure-samples/consumer-sample/pom.xml
@@ -13,21 +13,20 @@
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"
+ -->
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
- <groupId>com.alibaba.boot</groupId>
- <artifactId>dubbo-spring-boot-samples</artifactId>
+ <groupId>com.alibaba.boot.samples</groupId>
+ <artifactId>dubbo-spring-boot-auto-configure-samples</artifactId>
<version>0.1.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
- <artifactId>dubbo-spring-boot-sample-provider</artifactId>
- <name>Dubbo Spring Boot Sample : Provider </name>
-
+ <artifactId>dubbo-spring-boot-auto-configure-consumer-sample</artifactId>
+ <name>Dubbo Spring Boot Samples : Auto-Configure :: Consumer Sample</name>
<dependencies>
<!-- Spring Boot dependencies -->
@@ -37,17 +36,11 @@
</dependency>
<dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-actuator</artifactId>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
+ <groupId>com.alibaba.boot</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
<version>${project.version}</version>
</dependency>
- <!-- Dubbo -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>dubbo</artifactId>
@@ -78,5 +71,4 @@
</plugins>
</build>
-
</project>
\ No newline at end of file
diff --git a/dubbo-spring-boot-samples/auto-configure-samples/consumer-sample/src/main/java/com/alibaba/boot/dubbo/demo/consumer/bootstrap/DubboAutoConfigurationConsumerBootstrap.java b/dubbo-spring-boot-samples/auto-configure-samples/consumer-sample/src/main/java/com/alibaba/boot/dubbo/demo/consumer/bootstrap/DubboAutoConfigurationConsumerBootstrap.java
new file mode 100644
index 0000000..ec85a2f
--- /dev/null
+++ b/dubbo-spring-boot-samples/auto-configure-samples/consumer-sample/src/main/java/com/alibaba/boot/dubbo/demo/consumer/bootstrap/DubboAutoConfigurationConsumerBootstrap.java
@@ -0,0 +1,56 @@
+/*
+ * 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 com.alibaba.boot.dubbo.demo.consumer.bootstrap;
+
+import com.alibaba.boot.dubbo.demo.consumer.DemoService;
+import com.alibaba.dubbo.config.annotation.Reference;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.boot.ApplicationArguments;
+import org.springframework.boot.ApplicationRunner;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.context.annotation.Bean;
+
+/**
+ * Dubbo Auto Configuration Consumer Bootstrap
+ *
+ * @since 1.0.0
+ */
+@EnableAutoConfiguration
+public class DubboAutoConfigurationConsumerBootstrap {
+
+ private final Logger logger = LoggerFactory.getLogger(getClass());
+
+ @Reference(version = "1.0.0", url = "dubbo://localhost:12345")
+ private DemoService demoService;
+
+ @Bean
+ public ApplicationRunner runner() {
+ return new ApplicationRunner() {
+ @Override
+ public void run(ApplicationArguments args) throws Exception {
+ logger.info(demoService.sayHello("mercyblitz"));
+ }
+ };
+ }
+
+ public static void main(String[] args) {
+ SpringApplication.run(DubboAutoConfigurationConsumerBootstrap.class).close();
+ }
+}
diff --git a/dubbo-spring-boot-samples/auto-configure-samples/consumer-sample/src/main/resources/application.yml b/dubbo-spring-boot-samples/auto-configure-samples/consumer-sample/src/main/resources/application.yml
new file mode 100644
index 0000000..cb7b133
--- /dev/null
+++ b/dubbo-spring-boot-samples/auto-configure-samples/consumer-sample/src/main/resources/application.yml
@@ -0,0 +1,3 @@
+spring:
+ application:
+ name: dubbo-auto-configure-consumer-sample
\ No newline at end of file
diff --git a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-api/pom.xml b/dubbo-spring-boot-samples/auto-configure-samples/pom.xml
similarity index 67%
copy from dubbo-spring-boot-samples/dubbo-spring-boot-sample-api/pom.xml
copy to dubbo-spring-boot-samples/auto-configure-samples/pom.xml
index baf5da2..7e6b3c0 100644
--- a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-api/pom.xml
+++ b/dubbo-spring-boot-samples/auto-configure-samples/pom.xml
@@ -13,19 +13,26 @@
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"
+ -->
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
- <groupId>com.alibaba.boot</groupId>
+ <groupId>com.alibaba.boot.samples</groupId>
<artifactId>dubbo-spring-boot-samples</artifactId>
<version>0.1.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
- <artifactId>dubbo-spring-boot-sample-api</artifactId>
- <name>Dubbo Spring Boot Sample : API</name>
+ <artifactId>dubbo-spring-boot-auto-configure-samples</artifactId>
+ <name>Dubbo Spring Boot Samples : Auto-Configure</name>
+ <description>Dubbo Spring Boot Auto-Configure Samples</description>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>consumer-sample</module>
+ <module>provider-sample</module>
+ </modules>
</project>
\ No newline at end of file
diff --git a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-consumer/pom.xml b/dubbo-spring-boot-samples/auto-configure-samples/provider-sample/pom.xml
similarity index 78%
copy from dubbo-spring-boot-samples/dubbo-spring-boot-sample-consumer/pom.xml
copy to dubbo-spring-boot-samples/auto-configure-samples/provider-sample/pom.xml
index 3637b72..7f03257 100644
--- a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-consumer/pom.xml
+++ b/dubbo-spring-boot-samples/auto-configure-samples/provider-sample/pom.xml
@@ -13,41 +13,35 @@
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"
+ -->
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
- <groupId>com.alibaba.boot</groupId>
- <artifactId>dubbo-spring-boot-samples</artifactId>
+ <groupId>com.alibaba.boot.samples</groupId>
+ <artifactId>dubbo-spring-boot-auto-configure-samples</artifactId>
<version>0.1.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
- <artifactId>dubbo-spring-boot-sample-consumer</artifactId>
- <name>Dubbo Spring Boot Sample : Consumer</name>
+ <artifactId>dubbo-spring-boot-auto-configure-provider-sample</artifactId>
+ <name>Dubbo Spring Boot Samples : Auto-Configure :: Provider Sample</name>
<dependencies>
<!-- Spring Boot dependencies -->
<dependency>
<groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-web</artifactId>
+ <artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-actuator</artifactId>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
+ <groupId>com.alibaba.boot</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
<version>${project.version}</version>
</dependency>
- <!-- Dubbo -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>dubbo</artifactId>
@@ -78,4 +72,5 @@
</plugins>
</build>
+
</project>
\ No newline at end of file
diff --git a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/src/main/java/com/alibaba/boot/dubbo/demo/provider/bootstrap/DubboProviderDemo.java b/dubbo-spring-boot-samples/auto-configure-samples/provider-sample/src/main/java/com/alibaba/boot/dubbo/demo/provider/bootstrap/DubboAutoConfigurationProviderBootstrap.java
similarity index 80%
copy from dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/src/main/java/com/alibaba/boot/dubbo/demo/provider/bootstrap/DubboProviderDemo.java
copy to dubbo-spring-boot-samples/auto-configure-samples/provider-sample/src/main/java/com/alibaba/boot/dubbo/demo/provider/bootstrap/DubboAutoConfigurationProviderBootstrap.java
index 18f6ba7..4fc972d 100644
--- a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/src/main/java/com/alibaba/boot/dubbo/demo/provider/bootstrap/DubboProviderDemo.java
+++ b/dubbo-spring-boot-samples/auto-configure-samples/provider-sample/src/main/java/com/alibaba/boot/dubbo/demo/provider/bootstrap/DubboAutoConfigurationProviderBootstrap.java
@@ -18,21 +18,20 @@ package com.alibaba.boot.dubbo.demo.provider.bootstrap;
import com.alibaba.boot.dubbo.demo.provider.service.DefaultDemoService;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
/**
- * Dubbo Provider Demo
+ * Dubbo Auto-Configuration Provider Bootstrap
*
* @see DefaultDemoService
* @since 1.0.0
*/
-@SpringBootApplication
-public class DubboProviderDemo {
+@EnableAutoConfiguration
+public class DubboAutoConfigurationProviderBootstrap {
public static void main(String[] args) {
- new SpringApplicationBuilder(DubboProviderDemo.class)
- .profiles("prod")
+ new SpringApplicationBuilder(DubboAutoConfigurationProviderBootstrap.class)
.web(false)
.run(args);
}
diff --git a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/src/main/java/com/alibaba/boot/dubbo/demo/provider/service/DefaultDemoService.java b/dubbo-spring-boot-samples/auto-configure-samples/provider-sample/src/main/java/com/alibaba/boot/dubbo/demo/provider/service/DefaultDemoService.java
similarity index 77%
copy from dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/src/main/java/com/alibaba/boot/dubbo/demo/provider/service/DefaultDemoService.java
copy to dubbo-spring-boot-samples/auto-configure-samples/provider-sample/src/main/java/com/alibaba/boot/dubbo/demo/provider/service/DefaultDemoService.java
index 5a66cea..01dfccc 100644
--- a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/src/main/java/com/alibaba/boot/dubbo/demo/provider/service/DefaultDemoService.java
+++ b/dubbo-spring-boot-samples/auto-configure-samples/provider-sample/src/main/java/com/alibaba/boot/dubbo/demo/provider/service/DefaultDemoService.java
@@ -19,21 +19,24 @@ package com.alibaba.boot.dubbo.demo.provider.service;
import com.alibaba.boot.dubbo.demo.consumer.DemoService;
import com.alibaba.dubbo.config.annotation.Service;
+import org.springframework.beans.factory.annotation.Value;
+
/**
* Default {@link DemoService}
*
* @see DemoService
* @since 1.0.0
*/
-@Service(
- version = "${demo.service.version}",
- protocol = "${dubbo.protocol.id}",
- registry = "${dubbo.registry.id}"
-)
+@Service(version = "1.0.0")
public class DefaultDemoService implements DemoService {
+ /**
+ * The default value of ${dubbo.application.name} is ${spring.application.name}
+ */
+ @Value("${dubbo.application.name}")
+ private String serviceName;
+
public String sayHello(String name) {
- return "Hello, " + name + " (from Spring Boot)";
+ return String.format("[%s] : Hello, %s", serviceName, name);
}
-
}
\ No newline at end of file
diff --git a/dubbo-spring-boot-samples/auto-configure-samples/provider-sample/src/main/resources/application.properties b/dubbo-spring-boot-samples/auto-configure-samples/provider-sample/src/main/resources/application.properties
new file mode 100644
index 0000000..85e8400
--- /dev/null
+++ b/dubbo-spring-boot-samples/auto-configure-samples/provider-sample/src/main/resources/application.properties
@@ -0,0 +1,12 @@
+# Spring boot application
+spring.application.name=dubbo-auto-configuration-provider-demo
+# Base packages to scan Dubbo Component: @com.alibaba.dubbo.config.annotation.Service
+dubbo.scan.base-packages=com.alibaba.boot.dubbo.demo.provider.service
+# Dubbo Application
+## The default value of dubbo.application.name is ${spring.application.name}
+## dubbo.application.name=${spring.application.name}
+# Dubbo Protocol
+dubbo.protocol.name=dubbo
+dubbo.protocol.port=12345
+## Dubbo Registry
+dubbo.registry.address=N/A
\ No newline at end of file
diff --git a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/pom.xml b/dubbo-spring-boot-samples/dubbo-registry-nacos-samples/consumer-sample/pom.xml
similarity index 71%
copy from dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/pom.xml
copy to dubbo-spring-boot-samples/dubbo-registry-nacos-samples/consumer-sample/pom.xml
index 97365d7..9e75621 100644
--- a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/pom.xml
+++ b/dubbo-spring-boot-samples/dubbo-registry-nacos-samples/consumer-sample/pom.xml
@@ -13,23 +13,22 @@
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"
+ -->
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
- <groupId>com.alibaba.boot</groupId>
- <artifactId>dubbo-spring-boot-samples</artifactId>
+ <groupId>com.alibaba.boot.samples</groupId>
+ <artifactId>dubbo-spring-boot-registry-nacos-samples</artifactId>
<version>0.1.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
- <artifactId>dubbo-spring-boot-sample-provider</artifactId>
- <name>Dubbo Spring Boot Sample : Provider </name>
+ <artifactId>dubbo-spring-boot-registry-nacos-consumer-sample</artifactId>
+ <name>Dubbo Spring Boot Samples : Registry Nacos :: Consumer Sample</name>
<dependencies>
-
<!-- Spring Boot dependencies -->
<dependency>
<groupId>org.springframework.boot</groupId>
@@ -37,12 +36,7 @@
</dependency>
<dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-actuator</artifactId>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
+ <groupId>com.alibaba.boot</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
<version>${project.version}</version>
</dependency>
@@ -59,6 +53,24 @@
<version>${project.version}</version>
</dependency>
+ <!-- Netty -->
+ <dependency>
+ <groupId>io.netty</groupId>
+ <artifactId>netty-all</artifactId>
+ </dependency>
+
+ <!-- Dubbo Nacos registry dependency -->
+ <dependency>
+ <groupId>com.alibaba</groupId>
+ <artifactId>dubbo-registry-nacos</artifactId>
+ </dependency>
+
+ <!-- Keep latest Nacos client version -->
+ <dependency>
+ <groupId>com.alibaba.nacos</groupId>
+ <artifactId>nacos-client</artifactId>
+ </dependency>
+
</dependencies>
<build>
@@ -78,5 +90,4 @@
</plugins>
</build>
-
</project>
\ No newline at end of file
diff --git a/dubbo-spring-boot-samples/dubbo-registry-nacos-samples/consumer-sample/src/main/java/com/alibaba/boot/dubbo/demo/consumer/bootstrap/DubboRegistryNacosConsumerBootstrap.java b/dubbo-spring-boot-samples/dubbo-registry-nacos-samples/consumer-sample/src/main/java/com/alibaba/boot/dubbo/demo/consumer/bootstrap/DubboRegistryNacosConsumerBootstrap.java
new file mode 100644
index 0000000..6d88255
--- /dev/null
+++ b/dubbo-spring-boot-samples/dubbo-registry-nacos-samples/consumer-sample/src/main/java/com/alibaba/boot/dubbo/demo/consumer/bootstrap/DubboRegistryNacosConsumerBootstrap.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.alibaba.boot.dubbo.demo.consumer.bootstrap;
+
+import com.alibaba.boot.dubbo.demo.consumer.DemoService;
+import com.alibaba.dubbo.config.annotation.Reference;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.boot.ApplicationArguments;
+import org.springframework.boot.ApplicationRunner;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.context.annotation.Bean;
+
+/**
+ * Dubbo Registry Nacos Consumer Bootstrap
+ */
+@EnableAutoConfiguration
+public class DubboRegistryNacosConsumerBootstrap {
+
+ private final Logger logger = LoggerFactory.getLogger(getClass());
+
+ @Reference(version = "${demo.service.version}")
+ private DemoService demoService;
+
+ @Bean
+ public ApplicationRunner runner() {
+ return new ApplicationRunner() {
+ @Override
+ public void run(ApplicationArguments args) throws Exception {
+ logger.info(demoService.sayHello("mercyblitz"));
+ }
+ };
+ }
+
+ public static void main(String[] args) {
+ SpringApplication.run(DubboRegistryNacosConsumerBootstrap.class).close();
+ }
+}
diff --git a/dubbo-spring-boot-samples/dubbo-registry-nacos-samples/consumer-sample/src/main/resources/application.yml b/dubbo-spring-boot-samples/dubbo-registry-nacos-samples/consumer-sample/src/main/resources/application.yml
new file mode 100644
index 0000000..7889cf7
--- /dev/null
+++ b/dubbo-spring-boot-samples/dubbo-registry-nacos-samples/consumer-sample/src/main/resources/application.yml
@@ -0,0 +1,11 @@
+spring:
+ application:
+ name: dubbo-registry-nacos-consumer-sample
+
+demo:
+ service:
+ version: 1.0.0
+
+dubbo:
+ registry:
+ address: nacos://127.0.0.1:8848
\ No newline at end of file
diff --git a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-api/pom.xml b/dubbo-spring-boot-samples/dubbo-registry-nacos-samples/pom.xml
similarity index 67%
copy from dubbo-spring-boot-samples/dubbo-spring-boot-sample-api/pom.xml
copy to dubbo-spring-boot-samples/dubbo-registry-nacos-samples/pom.xml
index baf5da2..100f643 100644
--- a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-api/pom.xml
+++ b/dubbo-spring-boot-samples/dubbo-registry-nacos-samples/pom.xml
@@ -13,19 +13,26 @@
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"
+ -->
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
- <groupId>com.alibaba.boot</groupId>
+ <groupId>com.alibaba.boot.samples</groupId>
<artifactId>dubbo-spring-boot-samples</artifactId>
<version>0.1.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
- <artifactId>dubbo-spring-boot-sample-api</artifactId>
- <name>Dubbo Spring Boot Sample : API</name>
+ <artifactId>dubbo-spring-boot-registry-nacos-samples</artifactId>
+ <name>Dubbo Spring Boot Samples : Registry Nacos</name>
+ <description>Dubbo Spring Boot Registry Nacos Samples</description>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>consumer-sample</module>
+ <module>provider-sample</module>
+ </modules>
</project>
\ No newline at end of file
diff --git a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-consumer/pom.xml b/dubbo-spring-boot-samples/dubbo-registry-nacos-samples/provider-sample/pom.xml
similarity index 71%
rename from dubbo-spring-boot-samples/dubbo-spring-boot-sample-consumer/pom.xml
rename to dubbo-spring-boot-samples/dubbo-registry-nacos-samples/provider-sample/pom.xml
index 3637b72..1d7c7fa 100644
--- a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-consumer/pom.xml
+++ b/dubbo-spring-boot-samples/dubbo-registry-nacos-samples/provider-sample/pom.xml
@@ -13,20 +13,20 @@
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"
+ -->
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
- <groupId>com.alibaba.boot</groupId>
- <artifactId>dubbo-spring-boot-samples</artifactId>
+ <groupId>com.alibaba.boot.samples</groupId>
+ <artifactId>dubbo-spring-boot-registry-nacos-samples</artifactId>
<version>0.1.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
- <artifactId>dubbo-spring-boot-sample-consumer</artifactId>
- <name>Dubbo Spring Boot Sample : Consumer</name>
+ <artifactId>dubbo-spring-boot-registry-nacos-provider-sample</artifactId>
+ <name>Dubbo Spring Boot Samples : Registry Nacos :: Provider Sample</name>
<dependencies>
@@ -37,12 +37,7 @@
</dependency>
<dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-actuator</artifactId>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
+ <groupId>com.alibaba.boot</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
<version>${project.version}</version>
</dependency>
@@ -59,6 +54,23 @@
<version>${project.version}</version>
</dependency>
+ <!-- Netty -->
+ <dependency>
+ <groupId>io.netty</groupId>
+ <artifactId>netty-all</artifactId>
+ </dependency>
+
+ <!-- Dubbo Nacos registry dependency -->
+ <dependency>
+ <groupId>com.alibaba</groupId>
+ <artifactId>dubbo-registry-nacos</artifactId>
+ </dependency>
+
+ <!-- Keep latest Nacos client version -->
+ <dependency>
+ <groupId>com.alibaba.nacos</groupId>
+ <artifactId>nacos-client</artifactId>
+ </dependency>
</dependencies>
<build>
@@ -78,4 +90,5 @@
</plugins>
</build>
+
</project>
\ No newline at end of file
diff --git a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/src/main/java/com/alibaba/boot/dubbo/demo/provider/bootstrap/DubboProviderDemo.java b/dubbo-spring-boot-samples/dubbo-registry-nacos-samples/provider-sample/src/main/java/com/alibaba/boot/dubbo/demo/provider/bootstrap/DubboRegistryNacosProviderBootstrap.java
similarity index 79%
copy from dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/src/main/java/com/alibaba/boot/dubbo/demo/provider/bootstrap/DubboProviderDemo.java
copy to dubbo-spring-boot-samples/dubbo-registry-nacos-samples/provider-sample/src/main/java/com/alibaba/boot/dubbo/demo/provider/bootstrap/DubboRegistryNacosProviderBootstrap.java
index 18f6ba7..5fedfa7 100644
--- a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/src/main/java/com/alibaba/boot/dubbo/demo/provider/bootstrap/DubboProviderDemo.java
+++ b/dubbo-spring-boot-samples/dubbo-registry-nacos-samples/provider-sample/src/main/java/com/alibaba/boot/dubbo/demo/provider/bootstrap/DubboRegistryNacosProviderBootstrap.java
@@ -18,22 +18,21 @@ package com.alibaba.boot.dubbo.demo.provider.bootstrap;
import com.alibaba.boot.dubbo.demo.provider.service.DefaultDemoService;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
/**
- * Dubbo Provider Demo
+ * Dubbo Registry ZooKeeper Provider Bootstrap
*
* @see DefaultDemoService
* @since 1.0.0
*/
-@SpringBootApplication
-public class DubboProviderDemo {
+@EnableAutoConfiguration
+public class DubboRegistryNacosProviderBootstrap {
public static void main(String[] args) {
- new SpringApplicationBuilder(DubboProviderDemo.class)
- .profiles("prod")
+ new SpringApplicationBuilder(DubboRegistryNacosProviderBootstrap.class)
.web(false)
- .run(args);
+ .run();
}
}
diff --git a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-consumer/src/main/java/com/alibaba/boot/dubbo/demo/consumer/controller/DemoConsumerController.java b/dubbo-spring-boot-samples/dubbo-registry-nacos-samples/provider-sample/src/main/java/com/alibaba/boot/dubbo/demo/provider/service/DefaultDemoService.java
similarity index 56%
rename from dubbo-spring-boot-samples/dubbo-spring-boot-sample-consumer/src/main/java/com/alibaba/boot/dubbo/demo/consumer/controller/DemoConsumerController.java
rename to dubbo-spring-boot-samples/dubbo-registry-nacos-samples/provider-sample/src/main/java/com/alibaba/boot/dubbo/demo/provider/service/DefaultDemoService.java
index a2be819..f1d9ae1 100644
--- a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-consumer/src/main/java/com/alibaba/boot/dubbo/demo/consumer/controller/DemoConsumerController.java
+++ b/dubbo-spring-boot-samples/dubbo-registry-nacos-samples/provider-sample/src/main/java/com/alibaba/boot/dubbo/demo/provider/service/DefaultDemoService.java
@@ -14,31 +14,29 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.alibaba.boot.dubbo.demo.consumer.controller;
+package com.alibaba.boot.dubbo.demo.provider.service;
import com.alibaba.boot.dubbo.demo.consumer.DemoService;
-import com.alibaba.dubbo.config.annotation.Reference;
+import com.alibaba.dubbo.config.annotation.Service;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.beans.factory.annotation.Value;
/**
- * Demo Consumer Controller (REST)
+ * Default {@link DemoService}
*
- * @see RestController
+ * @see DemoService
* @since 1.0.0
*/
-@RestController
-public class DemoConsumerController {
+@Service(version = "${demo.service.version}")
+public class DefaultDemoService implements DemoService {
- @Reference(version = "${demo.service.version}",
- url = "dubbo://localhost:12345")
- private DemoService demoService;
+ /**
+ * The default value of ${dubbo.application.name} is ${spring.application.name}
+ */
+ @Value("${dubbo.application.name}")
+ private String serviceName;
- @RequestMapping("/sayHello")
- public String sayHello(@RequestParam String name) {
- return demoService.sayHello(name);
+ public String sayHello(String name) {
+ return String.format("[%s] : Hello, %s", serviceName, name);
}
-
-}
+}
\ No newline at end of file
diff --git a/dubbo-spring-boot-samples/dubbo-registry-nacos-samples/provider-sample/src/main/resources/application.properties b/dubbo-spring-boot-samples/dubbo-registry-nacos-samples/provider-sample/src/main/resources/application.properties
new file mode 100644
index 0000000..91635fb
--- /dev/null
+++ b/dubbo-spring-boot-samples/dubbo-registry-nacos-samples/provider-sample/src/main/resources/application.properties
@@ -0,0 +1,20 @@
+# Spring boot application
+spring.application.name=dubbo-registry-nacos-provider-sample
+
+# Base packages to scan Dubbo Component: @com.alibaba.dubbo.config.annotation.Service
+dubbo.scan.base-packages=com.alibaba.boot.dubbo.demo.provider.service
+
+# Dubbo Application
+## The default value of dubbo.application.name is ${spring.application.name}
+## dubbo.application.name=${spring.application.name}
+
+# Dubbo Protocol
+dubbo.protocol.name=dubbo
+## Random port
+dubbo.protocol.port=-1
+
+## Dubbo Registry
+dubbo.registry.address=nacos://127.0.0.1:8848
+
+## DemoService version
+demo.service.version=1.0.0
\ No newline at end of file
diff --git a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/pom.xml b/dubbo-spring-boot-samples/dubbo-registry-zookeeper-samples/consumer-sample/pom.xml
similarity index 80%
copy from dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/pom.xml
copy to dubbo-spring-boot-samples/dubbo-registry-zookeeper-samples/consumer-sample/pom.xml
index 97365d7..49d77ff 100644
--- a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/pom.xml
+++ b/dubbo-spring-boot-samples/dubbo-registry-zookeeper-samples/consumer-sample/pom.xml
@@ -13,21 +13,20 @@
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"
+ -->
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
- <groupId>com.alibaba.boot</groupId>
- <artifactId>dubbo-spring-boot-samples</artifactId>
+ <groupId>com.alibaba.boot.samples</groupId>
+ <artifactId>dubbo-spring-boot-registry-zookeeper-samples</artifactId>
<version>0.1.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
- <artifactId>dubbo-spring-boot-sample-provider</artifactId>
- <name>Dubbo Spring Boot Sample : Provider </name>
-
+ <artifactId>dubbo-spring-boot-registry-zookeeper-consumer-sample</artifactId>
+ <name>Dubbo Spring Boot Samples : Registry Zookeeper :: Consumer Sample</name>
<dependencies>
<!-- Spring Boot dependencies -->
@@ -37,17 +36,11 @@
</dependency>
<dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-actuator</artifactId>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
+ <groupId>com.alibaba.boot</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
<version>${project.version}</version>
</dependency>
- <!-- Dubbo -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>dubbo</artifactId>
@@ -59,6 +52,11 @@
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.curator</groupId>
+ <artifactId>curator-framework</artifactId>
+ </dependency>
+
</dependencies>
<build>
@@ -78,5 +76,4 @@
</plugins>
</build>
-
</project>
\ No newline at end of file
diff --git a/dubbo-spring-boot-samples/dubbo-registry-zookeeper-samples/consumer-sample/src/main/java/com/alibaba/boot/dubbo/demo/consumer/bootstrap/DubboRegistryZooKeeperConsumerBootstrap.java b/dubbo-spring-boot-samples/dubbo-registry-zookeeper-samples/consumer-sample/src/main/java/com/alibaba/boot/dubbo/demo/consumer/bootstrap/DubboRegistryZooKeeperConsumerBootstrap.java
new file mode 100644
index 0000000..c881b54
--- /dev/null
+++ b/dubbo-spring-boot-samples/dubbo-registry-zookeeper-samples/consumer-sample/src/main/java/com/alibaba/boot/dubbo/demo/consumer/bootstrap/DubboRegistryZooKeeperConsumerBootstrap.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.alibaba.boot.dubbo.demo.consumer.bootstrap;
+
+import com.alibaba.boot.dubbo.demo.consumer.DemoService;
+import com.alibaba.dubbo.config.annotation.Reference;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.boot.ApplicationArguments;
+import org.springframework.boot.ApplicationRunner;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.context.annotation.Bean;
+
+/**
+ * Dubbo Registry ZooKeeper Consumer Bootstrap
+ */
+@EnableAutoConfiguration
+public class DubboRegistryZooKeeperConsumerBootstrap {
+
+ private final Logger logger = LoggerFactory.getLogger(getClass());
+
+ @Reference(version = "${demo.service.version}")
+ private DemoService demoService;
+
+ @Bean
+ public ApplicationRunner runner() {
+ return new ApplicationRunner() {
+ @Override
+ public void run(ApplicationArguments args) throws Exception {
+ logger.info(demoService.sayHello("mercyblitz"));
+ }
+ };
+ }
+
+ public static void main(String[] args) {
+ SpringApplication.run(DubboRegistryZooKeeperConsumerBootstrap.class).close();
+ }
+}
diff --git a/dubbo-spring-boot-samples/dubbo-registry-zookeeper-samples/consumer-sample/src/main/resources/application.yml b/dubbo-spring-boot-samples/dubbo-registry-zookeeper-samples/consumer-sample/src/main/resources/application.yml
new file mode 100644
index 0000000..88846fb
--- /dev/null
+++ b/dubbo-spring-boot-samples/dubbo-registry-zookeeper-samples/consumer-sample/src/main/resources/application.yml
@@ -0,0 +1,15 @@
+spring:
+ application:
+ name: dubbo-registry-zookeeper-consumer-sample
+
+demo:
+ service:
+ version: 1.0.0
+
+embedded:
+ zookeeper:
+ port: 2181
+
+dubbo:
+ registry:
+ address: zookeeper://127.0.0.1:${embedded.zookeeper.port}
\ No newline at end of file
diff --git a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-api/pom.xml b/dubbo-spring-boot-samples/dubbo-registry-zookeeper-samples/pom.xml
similarity index 67%
copy from dubbo-spring-boot-samples/dubbo-spring-boot-sample-api/pom.xml
copy to dubbo-spring-boot-samples/dubbo-registry-zookeeper-samples/pom.xml
index baf5da2..434a5ff 100644
--- a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-api/pom.xml
+++ b/dubbo-spring-boot-samples/dubbo-registry-zookeeper-samples/pom.xml
@@ -13,19 +13,26 @@
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"
+ -->
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
- <groupId>com.alibaba.boot</groupId>
+ <groupId>com.alibaba.boot.samples</groupId>
<artifactId>dubbo-spring-boot-samples</artifactId>
<version>0.1.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
- <artifactId>dubbo-spring-boot-sample-api</artifactId>
- <name>Dubbo Spring Boot Sample : API</name>
+ <artifactId>dubbo-spring-boot-registry-zookeeper-samples</artifactId>
+ <name>Dubbo Spring Boot Samples : Registry Zookeeper</name>
+ <description>Dubbo Spring Boot Registry Zookeeper Samples</description>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>consumer-sample</module>
+ <module>provider-sample</module>
+ </modules>
</project>
\ No newline at end of file
diff --git a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/pom.xml b/dubbo-spring-boot-samples/dubbo-registry-zookeeper-samples/provider-sample/pom.xml
similarity index 76%
copy from dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/pom.xml
copy to dubbo-spring-boot-samples/dubbo-registry-zookeeper-samples/provider-sample/pom.xml
index 97365d7..fdcb98f 100644
--- a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/pom.xml
+++ b/dubbo-spring-boot-samples/dubbo-registry-zookeeper-samples/provider-sample/pom.xml
@@ -13,20 +13,20 @@
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"
+ -->
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
- <groupId>com.alibaba.boot</groupId>
- <artifactId>dubbo-spring-boot-samples</artifactId>
+ <groupId>com.alibaba.boot.samples</groupId>
+ <artifactId>dubbo-spring-boot-registry-zookeeper-samples</artifactId>
<version>0.1.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
- <artifactId>dubbo-spring-boot-sample-provider</artifactId>
- <name>Dubbo Spring Boot Sample : Provider </name>
+ <artifactId>dubbo-spring-boot-registry-zookeeper-provider-sample</artifactId>
+ <name>Dubbo Spring Boot Samples : Registry Zookeeper :: Provider Sample</name>
<dependencies>
@@ -37,12 +37,7 @@
</dependency>
<dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-actuator</artifactId>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
+ <groupId>com.alibaba.boot</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
<version>${project.version}</version>
</dependency>
@@ -59,6 +54,17 @@
<version>${project.version}</version>
</dependency>
+ <!-- Zookeeper -->
+ <dependency>
+ <groupId>org.apache.zookeeper</groupId>
+ <artifactId>zookeeper</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.curator</groupId>
+ <artifactId>curator-framework</artifactId>
+ </dependency>
+
</dependencies>
<build>
diff --git a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/src/main/java/com/alibaba/boot/dubbo/demo/provider/bootstrap/DubboProviderDemo.java b/dubbo-spring-boot-samples/dubbo-registry-zookeeper-samples/provider-sample/src/main/java/com/alibaba/boot/dubbo/demo/provider/bootstrap/DubboRegistryZooKeeperProviderBootstrap.java
similarity index 53%
rename from dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/src/main/java/com/alibaba/boot/dubbo/demo/provider/bootstrap/DubboProviderDemo.java
rename to dubbo-spring-boot-samples/dubbo-registry-zookeeper-samples/provider-sample/src/main/java/com/alibaba/boot/dubbo/demo/provider/bootstrap/DubboRegistryZooKeeperProviderBootstrap.java
index 18f6ba7..4290af3 100644
--- a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/src/main/java/com/alibaba/boot/dubbo/demo/provider/bootstrap/DubboProviderDemo.java
+++ b/dubbo-spring-boot-samples/dubbo-registry-zookeeper-samples/provider-sample/src/main/java/com/alibaba/boot/dubbo/demo/provider/bootstrap/DubboRegistryZooKeeperProviderBootstrap.java
@@ -18,22 +18,32 @@ package com.alibaba.boot.dubbo.demo.provider.bootstrap;
import com.alibaba.boot.dubbo.demo.provider.service.DefaultDemoService;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
+import org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent;
+import org.springframework.context.ApplicationListener;
+import org.springframework.core.env.Environment;
/**
- * Dubbo Provider Demo
+ * Dubbo Registry ZooKeeper Provider Bootstrap
*
* @see DefaultDemoService
* @since 1.0.0
*/
-@SpringBootApplication
-public class DubboProviderDemo {
+@EnableAutoConfiguration
+public class DubboRegistryZooKeeperProviderBootstrap {
public static void main(String[] args) {
- new SpringApplicationBuilder(DubboProviderDemo.class)
- .profiles("prod")
+ new SpringApplicationBuilder(DubboRegistryZooKeeperProviderBootstrap.class)
.web(false)
- .run(args);
+ .listeners(new ApplicationListener<ApplicationEnvironmentPreparedEvent>() {
+ @Override
+ public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) {
+ Environment environment = event.getEnvironment();
+ int port = environment.getProperty("embedded.zookeeper.port", int.class);
+ new EmbeddedZooKeeper(port, false).start();
+ }
+ }).
+ run(args);
}
}
diff --git a/dubbo-spring-boot-samples/dubbo-registry-zookeeper-samples/provider-sample/src/main/java/com/alibaba/boot/dubbo/demo/provider/bootstrap/EmbeddedZooKeeper.java b/dubbo-spring-boot-samples/dubbo-registry-zookeeper-samples/provider-sample/src/main/java/com/alibaba/boot/dubbo/demo/provider/bootstrap/EmbeddedZooKeeper.java
new file mode 100644
index 0000000..ced6344
--- /dev/null
+++ b/dubbo-spring-boot-samples/dubbo-registry-zookeeper-samples/provider-sample/src/main/java/com/alibaba/boot/dubbo/demo/provider/bootstrap/EmbeddedZooKeeper.java
@@ -0,0 +1,252 @@
+/*
+ * 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 com.alibaba.boot.dubbo.demo.provider.bootstrap;
+
+
+import org.apache.zookeeper.server.ServerConfig;
+import org.apache.zookeeper.server.ZooKeeperServerMain;
+import org.apache.zookeeper.server.quorum.QuorumPeerConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.SmartLifecycle;
+import org.springframework.util.ErrorHandler;
+import org.springframework.util.SocketUtils;
+
+import java.io.File;
+import java.lang.reflect.Method;
+import java.util.Properties;
+import java.util.UUID;
+
+/**
+ * from: https://github.com/spring-projects/spring-xd/blob/v1.3.1.RELEASE/spring-xd-dirt/src/main/java/org/springframework/xd/dirt/zookeeper/ZooKeeperUtils.java
+ * <p>
+ * Helper class to start an embedded instance of standalone (non clustered) ZooKeeper.
+ * <p>
+ * NOTE: at least an external standalone server (if not an ensemble) are recommended, even for
+ * org.springframework.xd.dirt.server.singlenode.SingleNodeApplication
+ *
+ * @author Patrick Peralta
+ * @author Mark Fisher
+ * @author David Turanski
+ */
+public class EmbeddedZooKeeper implements SmartLifecycle {
+
+ /**
+ * Logger.
+ */
+ private static final Logger logger = LoggerFactory.getLogger(EmbeddedZooKeeper.class);
+
+ /**
+ * ZooKeeper client port. This will be determined dynamically upon startup.
+ */
+ private final int clientPort;
+
+ /**
+ * Whether to auto-start. Default is true.
+ */
+ private boolean autoStartup = true;
+
+ /**
+ * Lifecycle phase. Default is 0.
+ */
+ private int phase = 0;
+
+ /**
+ * Thread for running the ZooKeeper server.
+ */
+ private volatile Thread zkServerThread;
+
+ /**
+ * ZooKeeper server.
+ */
+ private volatile ZooKeeperServerMain zkServer;
+
+ /**
+ * {@link ErrorHandler} to be invoked if an Exception is thrown from the ZooKeeper server thread.
+ */
+ private ErrorHandler errorHandler;
+
+ private boolean daemon = true;
+
+ /**
+ * Construct an EmbeddedZooKeeper with a random port.
+ */
+ public EmbeddedZooKeeper() {
+ clientPort = SocketUtils.findAvailableTcpPort();
+ }
+
+ /**
+ * Construct an EmbeddedZooKeeper with the provided port.
+ *
+ * @param clientPort port for ZooKeeper server to bind to
+ */
+ public EmbeddedZooKeeper(int clientPort, boolean daemon) {
+ this.clientPort = clientPort;
+ this.daemon = daemon;
+ }
+
+ /**
+ * Returns the port that clients should use to connect to this embedded server.
+ *
+ * @return dynamically determined client port
+ */
+ public int getClientPort() {
+ return this.clientPort;
+ }
+
+ /**
+ * Specify whether to start automatically. Default is true.
+ *
+ * @param autoStartup whether to start automatically
+ */
+ public void setAutoStartup(boolean autoStartup) {
+ this.autoStartup = autoStartup;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isAutoStartup() {
+ return this.autoStartup;
+ }
+
+ /**
+ * Specify the lifecycle phase for the embedded server.
+ *
+ * @param phase the lifecycle phase
+ */
+ public void setPhase(int phase) {
+ this.phase = phase;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int getPhase() {
+ return this.phase;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isRunning() {
+ return (zkServerThread != null);
+ }
+
+ /**
+ * Start the ZooKeeper server in a background thread.
+ * <p>
+ * Register an error handler via {@link #setErrorHandler} in order to handle
+ * any exceptions thrown during startup or execution.
+ */
+ @Override
+ public synchronized void start() {
+ if (zkServerThread == null) {
+ zkServerThread = new Thread(new ServerRunnable(), "ZooKeeper Server Starter");
+ zkServerThread.setDaemon(daemon);
+ zkServerThread.start();
+ }
+ }
+
+ /**
+ * Shutdown the ZooKeeper server.
+ */
+ @Override
+ public synchronized void stop() {
+ if (zkServerThread != null) {
+ // The shutdown method is protected...thus this hack to invoke it.
+ // This will log an exception on shutdown; see
+ // https://issues.apache.org/jira/browse/ZOOKEEPER-1873 for details.
+ try {
+ Method shutdown = ZooKeeperServerMain.class.getDeclaredMethod("shutdown");
+ shutdown.setAccessible(true);
+ shutdown.invoke(zkServer);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+
+ // It is expected that the thread will exit after
+ // the server is shutdown; this will block until
+ // the shutdown is complete.
+ try {
+ zkServerThread.join(5000);
+ zkServerThread = null;
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ logger.warn("Interrupted while waiting for embedded ZooKeeper to exit");
+ // abandoning zk thread
+ zkServerThread = null;
+ }
+ }
+ }
+
+ /**
+ * Stop the server if running and invoke the callback when complete.
+ */
+ @Override
+ public void stop(Runnable callback) {
+ stop();
+ callback.run();
+ }
+
+ /**
+ * Provide an {@link ErrorHandler} to be invoked if an Exception is thrown from the ZooKeeper server thread. If none
+ * is provided, only error-level logging will occur.
+ *
+ * @param errorHandler the {@link ErrorHandler} to be invoked
+ */
+ public void setErrorHandler(ErrorHandler errorHandler) {
+ this.errorHandler = errorHandler;
+ }
+
+ /**
+ * Runnable implementation that starts the ZooKeeper server.
+ */
+ private class ServerRunnable implements Runnable {
+
+ @Override
+ public void run() {
+ try {
+ Properties properties = new Properties();
+ File file = new File(System.getProperty("java.io.tmpdir")
+ + File.separator + UUID.randomUUID());
+ file.deleteOnExit();
+ properties.setProperty("dataDir", file.getAbsolutePath());
+ properties.setProperty("clientPort", String.valueOf(clientPort));
+
+ QuorumPeerConfig quorumPeerConfig = new QuorumPeerConfig();
+ quorumPeerConfig.parseProperties(properties);
+
+ zkServer = new ZooKeeperServerMain();
+ ServerConfig configuration = new ServerConfig();
+ configuration.readFrom(quorumPeerConfig);
+
+ zkServer.runFromConfig(configuration);
+ } catch (Exception e) {
+ if (errorHandler != null) {
+ errorHandler.handleError(e);
+ } else {
+ logger.error("Exception running embedded ZooKeeper", e);
+ }
+ }
+ }
+ }
+
+}
diff --git a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/src/main/java/com/alibaba/boot/dubbo/demo/provider/service/DefaultDemoService.java b/dubbo-spring-boot-samples/dubbo-registry-zookeeper-samples/provider-sample/src/main/java/com/alibaba/boot/dubbo/demo/provider/service/DefaultDemoService.java
similarity index 76%
copy from dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/src/main/java/com/alibaba/boot/dubbo/demo/provider/service/DefaultDemoService.java
copy to dubbo-spring-boot-samples/dubbo-registry-zookeeper-samples/provider-sample/src/main/java/com/alibaba/boot/dubbo/demo/provider/service/DefaultDemoService.java
index 5a66cea..f1d9ae1 100644
--- a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/src/main/java/com/alibaba/boot/dubbo/demo/provider/service/DefaultDemoService.java
+++ b/dubbo-spring-boot-samples/dubbo-registry-zookeeper-samples/provider-sample/src/main/java/com/alibaba/boot/dubbo/demo/provider/service/DefaultDemoService.java
@@ -19,21 +19,24 @@ package com.alibaba.boot.dubbo.demo.provider.service;
import com.alibaba.boot.dubbo.demo.consumer.DemoService;
import com.alibaba.dubbo.config.annotation.Service;
+import org.springframework.beans.factory.annotation.Value;
+
/**
* Default {@link DemoService}
*
* @see DemoService
* @since 1.0.0
*/
-@Service(
- version = "${demo.service.version}",
- protocol = "${dubbo.protocol.id}",
- registry = "${dubbo.registry.id}"
-)
+@Service(version = "${demo.service.version}")
public class DefaultDemoService implements DemoService {
+ /**
+ * The default value of ${dubbo.application.name} is ${spring.application.name}
+ */
+ @Value("${dubbo.application.name}")
+ private String serviceName;
+
public String sayHello(String name) {
- return "Hello, " + name + " (from Spring Boot)";
+ return String.format("[%s] : Hello, %s", serviceName, name);
}
-
}
\ No newline at end of file
diff --git a/dubbo-spring-boot-samples/dubbo-registry-zookeeper-samples/provider-sample/src/main/resources/application.properties b/dubbo-spring-boot-samples/dubbo-registry-zookeeper-samples/provider-sample/src/main/resources/application.properties
new file mode 100644
index 0000000..30aa324
--- /dev/null
+++ b/dubbo-spring-boot-samples/dubbo-registry-zookeeper-samples/provider-sample/src/main/resources/application.properties
@@ -0,0 +1,22 @@
+# Spring boot application
+spring.application.name=dubbo-registry-zookeeper-provider-sample
+
+# Base packages to scan Dubbo Component: @com.alibaba.dubbo.config.annotation.Service
+dubbo.scan.base-packages=com.alibaba.boot.dubbo.demo.provider.service
+
+# Dubbo Application
+## The default value of dubbo.application.name is ${spring.application.name}
+## dubbo.application.name=${spring.application.name}
+
+embedded.zookeeper.port = 2181
+
+# Dubbo Protocol
+dubbo.protocol.name=dubbo
+## Random port
+dubbo.protocol.port=-1
+
+## Dubbo Registry
+dubbo.registry.address=zookeeper://127.0.0.1:${embedded.zookeeper.port}
+
+## DemoService version
+demo.service.version=1.0.0
\ No newline at end of file
diff --git a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-consumer/src/main/resources/application.yml b/dubbo-spring-boot-samples/dubbo-spring-boot-sample-consumer/src/main/resources/application.yml
deleted file mode 100644
index b61aec0..0000000
--- a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-consumer/src/main/resources/application.yml
+++ /dev/null
@@ -1,31 +0,0 @@
-spring:
- application:
- name: dubbo-consumer-demo
-
-server:
- port: 8080
-
-management:
- port: 8081
- security:
- enabled: false
-
-dubbo:
- protocol:
- id: dubbo
- name: dubbo
- port: 12345
-
----
-spring:
- profiles: prod
-
-endpoints:
- dubbo:
- enabled: false
-
-management:
- health:
- dubbo:
- status:
- defaults: memory
\ No newline at end of file
diff --git a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/src/main/resources/application-prod.properties b/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/src/main/resources/application-prod.properties
deleted file mode 100644
index 421a140..0000000
--- a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/src/main/resources/application-prod.properties
+++ /dev/null
@@ -1,9 +0,0 @@
-# Application properties on prod profile
-# Dubbo Endpoint (default status is disable)
-endpoints.dubbo.enabled = true
-
-# Dubbo Health
-## StatusChecker Name defaults (default : "memory", "load" )
-management.health.dubbo.status.defaults = memory
-## StatusChecker Name extras (default : empty )
-management.health.dubbo.status.extras = load,threadpool
\ No newline at end of file
diff --git a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/src/main/resources/application.properties b/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/src/main/resources/application.properties
deleted file mode 100644
index d0d1f2c..0000000
--- a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/src/main/resources/application.properties
+++ /dev/null
@@ -1,25 +0,0 @@
-# Spring boot application
-spring.application.name = dubbo-provider-demo
-server.port = 9090
-management.security.enabled = false
-
-# Service Version
-demo.service.version = 1.0.0
-
-# Base packages to scan Dubbo Components (e.g @Service , @Reference)
-dubbo.scan.basePackages = com.alibaba.boot.dubbo.demo.provider.service
-
-# Dubbo Config properties
-## ApplicationConfig Bean
-dubbo.application.qos.port=22222
-dubbo.application.qos.enable=true
-
-## ProtocolConfig Bean
-dubbo.protocol.id = dubbo
-dubbo.protocol.name = dubbo
-dubbo.protocol.port = 12345
-dubbo.protocol.status = server
-
-## RegistryConfig Bean
-dubbo.registry.id = my-registry
-dubbo.registry.address = N/A
\ No newline at end of file
diff --git a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/pom.xml b/dubbo-spring-boot-samples/externalized-configuration-samples/consumer-sample/pom.xml
similarity index 79%
copy from dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/pom.xml
copy to dubbo-spring-boot-samples/externalized-configuration-samples/consumer-sample/pom.xml
index 97365d7..d884910 100644
--- a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/pom.xml
+++ b/dubbo-spring-boot-samples/externalized-configuration-samples/consumer-sample/pom.xml
@@ -13,21 +13,20 @@
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"
+ -->
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
- <groupId>com.alibaba.boot</groupId>
- <artifactId>dubbo-spring-boot-samples</artifactId>
+ <groupId>com.alibaba.boot.samples</groupId>
+ <artifactId>dubbo-spring-boot-externalized-configuration-samples</artifactId>
<version>0.1.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
- <artifactId>dubbo-spring-boot-sample-provider</artifactId>
- <name>Dubbo Spring Boot Sample : Provider </name>
-
+ <artifactId>dubbo-spring-boot-externalized-configuration-consumer-sample</artifactId>
+ <name>Dubbo Spring Boot Samples : Externalized Configuration :: Consumer Sample</name>
<dependencies>
<!-- Spring Boot dependencies -->
@@ -37,17 +36,11 @@
</dependency>
<dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-actuator</artifactId>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
+ <groupId>com.alibaba.boot</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
<version>${project.version}</version>
</dependency>
- <!-- Dubbo -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>dubbo</artifactId>
@@ -78,5 +71,4 @@
</plugins>
</build>
-
</project>
\ No newline at end of file
diff --git a/dubbo-spring-boot-samples/externalized-configuration-samples/consumer-sample/src/main/java/com/alibaba/boot/dubbo/demo/consumer/bootstrap/DubboExternalizedConfigurationConsumerBootstrap.java b/dubbo-spring-boot-samples/externalized-configuration-samples/consumer-sample/src/main/java/com/alibaba/boot/dubbo/demo/consumer/bootstrap/DubboExternalizedConfigurationConsumerBootstrap.java
new file mode 100644
index 0000000..6819e2e
--- /dev/null
+++ b/dubbo-spring-boot-samples/externalized-configuration-samples/consumer-sample/src/main/java/com/alibaba/boot/dubbo/demo/consumer/bootstrap/DubboExternalizedConfigurationConsumerBootstrap.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.alibaba.boot.dubbo.demo.consumer.bootstrap;
+
+import com.alibaba.boot.dubbo.demo.consumer.DemoService;
+import com.alibaba.dubbo.config.annotation.Reference;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.boot.ApplicationArguments;
+import org.springframework.boot.ApplicationRunner;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.context.annotation.Bean;
+
+/**
+ * Dubbo Externalized Configuration Consumer Bootstrap
+ */
+@EnableAutoConfiguration
+public class DubboExternalizedConfigurationConsumerBootstrap {
+
+ private final Logger logger = LoggerFactory.getLogger(getClass());
+
+ @Reference(version = "${demo.service.version}", url = "${demo.service.url}")
+ private DemoService demoService;
+
+ @Bean
+ public ApplicationRunner runner() {
+ return new ApplicationRunner() {
+ @Override
+ public void run(ApplicationArguments args) throws Exception {
+ logger.info(demoService.sayHello("mercyblitz"));
+ }
+ };
+ }
+
+ public static void main(String[] args) {
+ SpringApplication.run(DubboExternalizedConfigurationConsumerBootstrap.class).close();
+ }
+}
diff --git a/dubbo-spring-boot-samples/externalized-configuration-samples/consumer-sample/src/main/resources/application.yml b/dubbo-spring-boot-samples/externalized-configuration-samples/consumer-sample/src/main/resources/application.yml
new file mode 100644
index 0000000..e3aef42
--- /dev/null
+++ b/dubbo-spring-boot-samples/externalized-configuration-samples/consumer-sample/src/main/resources/application.yml
@@ -0,0 +1,8 @@
+spring:
+ application:
+ name: dubbo-externalized-configuration-consumer-sample
+
+demo:
+ service:
+ version: 1.0.0
+ url: dubbo://localhost:12345
\ No newline at end of file
diff --git a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-api/pom.xml b/dubbo-spring-boot-samples/externalized-configuration-samples/pom.xml
similarity index 73%
copy from dubbo-spring-boot-samples/dubbo-spring-boot-sample-api/pom.xml
copy to dubbo-spring-boot-samples/externalized-configuration-samples/pom.xml
index baf5da2..89d3b2d 100644
--- a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-api/pom.xml
+++ b/dubbo-spring-boot-samples/externalized-configuration-samples/pom.xml
@@ -13,19 +13,27 @@
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>
- <groupId>com.alibaba.boot</groupId>
+ <groupId>com.alibaba.boot.samples</groupId>
<artifactId>dubbo-spring-boot-samples</artifactId>
<version>0.1.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
- <artifactId>dubbo-spring-boot-sample-api</artifactId>
- <name>Dubbo Spring Boot Sample : API</name>
+ <artifactId>dubbo-spring-boot-externalized-configuration-samples</artifactId>
+ <name>Dubbo Spring Boot Samples : Externalized Configuration</name>
+ <description>Dubbo Spring Boot Externalized Configuration Samples</description>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>consumer-sample</module>
+ <module>provider-sample</module>
+ </modules>
+
</project>
\ No newline at end of file
diff --git a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/pom.xml b/dubbo-spring-boot-samples/externalized-configuration-samples/provider-sample/pom.xml
similarity index 80%
rename from dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/pom.xml
rename to dubbo-spring-boot-samples/externalized-configuration-samples/provider-sample/pom.xml
index 97365d7..8261c05 100644
--- a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/pom.xml
+++ b/dubbo-spring-boot-samples/externalized-configuration-samples/provider-sample/pom.xml
@@ -13,20 +13,20 @@
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"
+ -->
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
- <groupId>com.alibaba.boot</groupId>
- <artifactId>dubbo-spring-boot-samples</artifactId>
+ <groupId>com.alibaba.boot.samples</groupId>
+ <artifactId>dubbo-spring-boot-externalized-configuration-samples</artifactId>
<version>0.1.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
- <artifactId>dubbo-spring-boot-sample-provider</artifactId>
- <name>Dubbo Spring Boot Sample : Provider </name>
+ <artifactId>dubbo-spring-boot-externalized-configuration-provider-sample</artifactId>
+ <name>Dubbo Spring Boot Samples : Externalized Configuration :: Provider Sample</name>
<dependencies>
@@ -37,17 +37,11 @@
</dependency>
<dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-actuator</artifactId>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
+ <groupId>com.alibaba.boot</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
<version>${project.version}</version>
</dependency>
- <!-- Dubbo -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>dubbo</artifactId>
diff --git a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-consumer/src/main/java/com/alibaba/boot/dubbo/demo/consumer/bootstrap/DubboConsumerDemo.java b/dubbo-spring-boot-samples/externalized-configuration-samples/provider-sample/src/main/java/com/alibaba/boot/dubbo/demo/provider/bootstrap/DubboExternalizedConfigurationProviderBootstrap.java
similarity index 66%
rename from dubbo-spring-boot-samples/dubbo-spring-boot-sample-consumer/src/main/java/com/alibaba/boot/dubbo/demo/consumer/bootstrap/DubboConsumerDemo.java
rename to dubbo-spring-boot-samples/externalized-configuration-samples/provider-sample/src/main/java/com/alibaba/boot/dubbo/demo/provider/bootstrap/DubboExternalizedConfigurationProviderBootstrap.java
index 12fb7b7..a47c4c1 100644
--- a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-consumer/src/main/java/com/alibaba/boot/dubbo/demo/consumer/bootstrap/DubboConsumerDemo.java
+++ b/dubbo-spring-boot-samples/externalized-configuration-samples/provider-sample/src/main/java/com/alibaba/boot/dubbo/demo/provider/bootstrap/DubboExternalizedConfigurationProviderBootstrap.java
@@ -14,25 +14,25 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.alibaba.boot.dubbo.demo.consumer.bootstrap;
+package com.alibaba.boot.dubbo.demo.provider.bootstrap;
-import com.alibaba.boot.dubbo.demo.consumer.controller.DemoConsumerController;
+import com.alibaba.boot.dubbo.demo.provider.service.DefaultDemoService;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
/**
- * Dubbo Consumer Demo
+ * Dubbo Externalized Configuration Provider Bootstrap
*
- * @see DemoConsumerController
+ * @see DefaultDemoService
* @since 1.0.0
*/
-@SpringBootApplication(scanBasePackages = "com.alibaba.boot.dubbo.demo.consumer.controller")
-public class DubboConsumerDemo {
+@EnableAutoConfiguration
+public class DubboExternalizedConfigurationProviderBootstrap {
public static void main(String[] args) {
- new SpringApplicationBuilder(DubboConsumerDemo.class)
- .profiles("prod")
+ new SpringApplicationBuilder(DubboExternalizedConfigurationProviderBootstrap.class)
+ .web(false)
.run(args);
}
}
diff --git a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/src/main/java/com/alibaba/boot/dubbo/demo/provider/service/DefaultDemoService.java b/dubbo-spring-boot-samples/externalized-configuration-samples/provider-sample/src/main/java/com/alibaba/boot/dubbo/demo/provider/service/DefaultDemoService.java
similarity index 76%
rename from dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/src/main/java/com/alibaba/boot/dubbo/demo/provider/service/DefaultDemoService.java
rename to dubbo-spring-boot-samples/externalized-configuration-samples/provider-sample/src/main/java/com/alibaba/boot/dubbo/demo/provider/service/DefaultDemoService.java
index 5a66cea..f1d9ae1 100644
--- a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/src/main/java/com/alibaba/boot/dubbo/demo/provider/service/DefaultDemoService.java
+++ b/dubbo-spring-boot-samples/externalized-configuration-samples/provider-sample/src/main/java/com/alibaba/boot/dubbo/demo/provider/service/DefaultDemoService.java
@@ -19,21 +19,24 @@ package com.alibaba.boot.dubbo.demo.provider.service;
import com.alibaba.boot.dubbo.demo.consumer.DemoService;
import com.alibaba.dubbo.config.annotation.Service;
+import org.springframework.beans.factory.annotation.Value;
+
/**
* Default {@link DemoService}
*
* @see DemoService
* @since 1.0.0
*/
-@Service(
- version = "${demo.service.version}",
- protocol = "${dubbo.protocol.id}",
- registry = "${dubbo.registry.id}"
-)
+@Service(version = "${demo.service.version}")
public class DefaultDemoService implements DemoService {
+ /**
+ * The default value of ${dubbo.application.name} is ${spring.application.name}
+ */
+ @Value("${dubbo.application.name}")
+ private String serviceName;
+
public String sayHello(String name) {
- return "Hello, " + name + " (from Spring Boot)";
+ return String.format("[%s] : Hello, %s", serviceName, name);
}
-
}
\ No newline at end of file
diff --git a/dubbo-spring-boot-samples/externalized-configuration-samples/provider-sample/src/main/resources/application.properties b/dubbo-spring-boot-samples/externalized-configuration-samples/provider-sample/src/main/resources/application.properties
new file mode 100644
index 0000000..398e996
--- /dev/null
+++ b/dubbo-spring-boot-samples/externalized-configuration-samples/provider-sample/src/main/resources/application.properties
@@ -0,0 +1,19 @@
+# Spring boot application
+spring.application.name=dubbo-externalized-configuration-provider-sample
+
+# Base packages to scan Dubbo Component: @com.alibaba.dubbo.config.annotation.Service
+dubbo.scan.base-packages=com.alibaba.boot.dubbo.demo.provider.service
+
+# Dubbo Application
+## The default value of dubbo.application.name is ${spring.application.name}
+## dubbo.application.name=${spring.application.name}
+
+# Dubbo Protocol
+dubbo.protocol.name=dubbo
+dubbo.protocol.port=12345
+
+## Dubbo Registry
+dubbo.registry.address=N/A
+
+## DemoService version
+demo.service.version=1.0.0
\ No newline at end of file
diff --git a/dubbo-spring-boot-samples/pom.xml b/dubbo-spring-boot-samples/pom.xml
index 28aab44..1d4d549 100644
--- a/dubbo-spring-boot-samples/pom.xml
+++ b/dubbo-spring-boot-samples/pom.xml
@@ -25,14 +25,18 @@
</parent>
<modelVersion>4.0.0</modelVersion>
+ <groupId>com.alibaba.boot.samples</groupId>
<artifactId>dubbo-spring-boot-samples</artifactId>
<packaging>pom</packaging>
<name>Dubbo Spring Boot Samples</name>
<description>Dubbo Spring Boot Samples</description>
+
<modules>
- <module>dubbo-spring-boot-sample-provider</module>
- <module>dubbo-spring-boot-sample-consumer</module>
- <module>dubbo-spring-boot-sample-api</module>
+ <module>sample-api</module>
+ <module>auto-configure-samples</module>
+ <module>externalized-configuration-samples</module>
+ <module>dubbo-registry-nacos-samples</module>
+ <module>dubbo-registry-zookeeper-samples</module>
</modules>
<dependencies>
diff --git a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-api/pom.xml b/dubbo-spring-boot-samples/sample-api/pom.xml
similarity index 91%
rename from dubbo-spring-boot-samples/dubbo-spring-boot-sample-api/pom.xml
rename to dubbo-spring-boot-samples/sample-api/pom.xml
index baf5da2..1278e68 100644
--- a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-api/pom.xml
+++ b/dubbo-spring-boot-samples/sample-api/pom.xml
@@ -13,12 +13,12 @@
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>
- <groupId>com.alibaba.boot</groupId>
+ <groupId>com.alibaba.boot.samples</groupId>
<artifactId>dubbo-spring-boot-samples</artifactId>
<version>0.1.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
@@ -26,6 +26,6 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>dubbo-spring-boot-sample-api</artifactId>
- <name>Dubbo Spring Boot Sample : API</name>
+ <name>Dubbo Spring Boot Samples : API</name>
</project>
\ No newline at end of file
diff --git a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-api/src/main/java/com/alibaba/boot/dubbo/demo/consumer/DemoService.java b/dubbo-spring-boot-samples/sample-api/src/main/java/com/alibaba/boot/dubbo/demo/consumer/DemoService.java
similarity index 100%
rename from dubbo-spring-boot-samples/dubbo-spring-boot-sample-api/src/main/java/com/alibaba/boot/dubbo/demo/consumer/DemoService.java
rename to dubbo-spring-boot-samples/sample-api/src/main/java/com/alibaba/boot/dubbo/demo/consumer/DemoService.java