diff --git a/.travis.yml b/.travis.yml index 5883b8911..71e20320e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,8 +2,8 @@ language: java sudo: false # faster builds jdk: - - oraclejdk10 - - oraclejdk9 + - openjdk10 + - openjdk9 - oraclejdk8 script: "mvn clean package" diff --git a/README.md b/README.md index 2c4db88c3..1d90f7ad6 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ You can introduce the latest `dubbo-spring-boot-starter` to your project by addi com.alibaba.boot dubbo-spring-boot-starter - 0.2.0 + 0.2.1-SNAPSHOT diff --git a/README_CN.md b/README_CN.md index fb19660d2..bdf584012 100644 --- a/README_CN.md +++ b/README_CN.md @@ -26,7 +26,7 @@ com.alibaba.boot dubbo-spring-boot-starter - 0.2.0 + 0.2.1-SNAPSHOT diff --git a/dubbo-spring-boot-actuator/README.md b/dubbo-spring-boot-actuator/README.md index 103aa7dad..401729256 100644 --- a/dubbo-spring-boot-actuator/README.md +++ b/dubbo-spring-boot-actuator/README.md @@ -33,7 +33,7 @@ You can introduce the latest `dubbo-spring-boot-actuator` to your project by ad com.alibaba.boot dubbo-spring-boot-actuator - 0.2.0 + 0.2.1-SNAPSHOT ``` If your project failed to resolve the dependency, try to add the following repository: @@ -162,11 +162,11 @@ Actuator endpoint `dubbo` supports Actuator Endpoints : | ID | Enabled | HTTP URI | HTTP Method | Description | Content Type | | ------------------- | ----------- | ----------------------------------- | ------------------ | ------------------ | ------------------ | | `dubbo` | `true` | `/actuator/dubbo` | `GET` | Exposes Dubbo's meta data | `application/json` | -| `dubbo-properties` | `true` | `/actuator/dubbo/properties` | `GET` | Exposes all Dubbo's Properties | `application/json` | -| `dubbo-services` | `false` | `/dubbo/services` | `GET` | Exposes all Dubbo's `ServiceBean` | `application/json` | -| `dubbo-references` | `false` | `/actuator/dubbo/references` | `GET` | Exposes all Dubbo's `ReferenceBean` | `application/json` | -| `dubbo-configs` | `true` | `/actuator/dubbo/configs` | `GET` | Exposes all Dubbo's `*Config` | `application/json` | -| `dubbo-shutdown` | `false` | `/actuator/dubbo/shutdown` | `POST` | Shutdown Dubbo services | `application/json` | +| `dubboProperties` | `true` | `/actuator/dubbo/properties` | `GET` | Exposes all Dubbo's Properties | `application/json` | +| `dubboServices` | `false` | `/dubbo/services` | `GET` | Exposes all Dubbo's `ServiceBean` | `application/json` | +| `dubboReferences` | `false` | `/actuator/dubbo/references` | `GET` | Exposes all Dubbo's `ReferenceBean` | `application/json` | +| `dubboConfigs` | `true` | `/actuator/dubbo/configs` | `GET` | Exposes all Dubbo's `*Config` | `application/json` | +| `dubboShutdown` | `false` | `/actuator/dubbo/shutdown` | `POST` | Shutdown Dubbo services | `application/json` | @@ -184,7 +184,7 @@ Actuator endpoint `dubbo` supports Actuator Endpoints : { "timestamp": 1516623290166, "versions": { - "dubbo-spring-boot": "0.2.0" + "dubbo-spring-boot": "0.2.0", "dubbo": "2.6.2" }, "urls": { @@ -503,10 +503,10 @@ Dubbo Spring Boot providers actuator endpoints , however some of them are disabl ```properties # Enables Dubbo All Endpoints management.endpoint.dubbo.enabled = true -management.endpoint.dubbo-shutdown.enabled = true -management.endpoint.dubbo-configs.enabled = true -management.endpoint.dubbo-services.enabled = true -management.endpoint.dubbo-references.enabled = true -management.endpoint.dubbo-properties.enabled = true +management.endpoint.dubboShutdown.enabled = true +management.endpoint.dubboConfigs.enabled = true +management.endpoint.dubboServices.enabled = true +management.endpoint.dubboReferences.enabled = true +management.endpoint.dubboProperties.enabled = true ``` diff --git a/dubbo-spring-boot-actuator/README_CN.md b/dubbo-spring-boot-actuator/README_CN.md index 395e3efcb..54db9ccc8 100644 --- a/dubbo-spring-boot-actuator/README_CN.md +++ b/dubbo-spring-boot-actuator/README_CN.md @@ -31,14 +31,14 @@ com.alibaba.boot dubbo-spring-boot-starter - 0.2.0 + 0.2.1-SNAPSHOT com.alibaba.boot dubbo-spring-boot-actuator - 0.2.0 + 0.2.1-SNAPSHOT ... diff --git a/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboConfigsMetadataEndpoint.java b/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboConfigsMetadataEndpoint.java index b5ae637e8..3bdccb33a 100644 --- a/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboConfigsMetadataEndpoint.java +++ b/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboConfigsMetadataEndpoint.java @@ -16,7 +16,18 @@ */ package com.alibaba.boot.dubbo.actuate.endpoint; -import com.alibaba.dubbo.config.*; +import com.alibaba.dubbo.config.AbstractConfig; +import com.alibaba.dubbo.config.ApplicationConfig; +import com.alibaba.dubbo.config.ConsumerConfig; +import com.alibaba.dubbo.config.MethodConfig; +import com.alibaba.dubbo.config.ModuleConfig; +import com.alibaba.dubbo.config.MonitorConfig; +import com.alibaba.dubbo.config.ProtocolConfig; +import com.alibaba.dubbo.config.ProviderConfig; +import com.alibaba.dubbo.config.ReferenceConfig; +import com.alibaba.dubbo.config.RegistryConfig; +import com.alibaba.dubbo.config.ServiceConfig; + import org.springframework.boot.actuate.endpoint.annotation.Endpoint; import org.springframework.boot.actuate.endpoint.annotation.ReadOperation; @@ -32,7 +43,7 @@ * @author Mercy * @since 0.2.0 */ -@Endpoint(id = "dubbo-configs") +@Endpoint(id = "dubboConfigs") public class DubboConfigsMetadataEndpoint extends AbstractDubboEndpoint { @ReadOperation diff --git a/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboEndpoint.java b/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboEndpoint.java index d5d503f07..792374613 100644 --- a/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboEndpoint.java +++ b/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboEndpoint.java @@ -18,14 +18,18 @@ import com.alibaba.boot.dubbo.util.DubboUtils; import com.alibaba.dubbo.common.Version; + import org.springframework.boot.actuate.endpoint.annotation.Endpoint; import org.springframework.boot.actuate.endpoint.annotation.ReadOperation; import java.util.LinkedHashMap; import java.util.Map; -import static com.alibaba.boot.dubbo.actuate.endpoint.DubboEndpoint.DUBBO_ENDPOINT_ID; -import static com.alibaba.boot.dubbo.util.DubboUtils.*; +import static com.alibaba.boot.dubbo.util.DubboUtils.DUBBO_GITHUB_URL; +import static com.alibaba.boot.dubbo.util.DubboUtils.DUBBO_MAILING_LIST; +import static com.alibaba.boot.dubbo.util.DubboUtils.DUBBO_SPRING_BOOT_GITHUB_URL; +import static com.alibaba.boot.dubbo.util.DubboUtils.DUBBO_SPRING_BOOT_GIT_URL; +import static com.alibaba.boot.dubbo.util.DubboUtils.DUBBO_SPRING_BOOT_ISSUES_URL; /** * Actuator {@link Endpoint} to expose Dubbo Meta Data @@ -34,21 +38,9 @@ * @see Endpoint * @since 1.0.0 */ -@Endpoint(id = DUBBO_ENDPOINT_ID) +@Endpoint(id = "dubbo") public class DubboEndpoint { - public static final String DUBBO_ENDPOINT_ID = "dubbo"; - - public static final String DUBBO_SHUTDOWN_ENDPOINT_ID = DUBBO_ENDPOINT_ID + "-shutdown"; - - public static final String DUBBO_CONFIGS_ENDPOINT_ID = DUBBO_ENDPOINT_ID + "-configs"; - - public static final String DUBBO_SERVICES_ENDPOINT_ID = DUBBO_ENDPOINT_ID + "-services"; - - public static final String DUBBO_REFERENCES_ENDPOINT_ID = DUBBO_ENDPOINT_ID + "-references"; - - public static final String DUBBO_PROPERTIES_ENDPOINT_ID = DUBBO_ENDPOINT_ID + "-properties"; - @ReadOperation public Map invoke() { diff --git a/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboPropertiesEndpoint.java b/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboPropertiesEndpoint.java index eeec4c9d6..23fad4e8c 100644 --- a/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboPropertiesEndpoint.java +++ b/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboPropertiesEndpoint.java @@ -21,7 +21,6 @@ import java.util.SortedMap; -import static com.alibaba.boot.dubbo.actuate.endpoint.DubboEndpoint.DUBBO_PROPERTIES_ENDPOINT_ID; import static com.alibaba.boot.dubbo.util.DubboUtils.filterDubboProperties; /** @@ -30,7 +29,7 @@ * @author Mercy * @since 1.0.0 */ -@Endpoint(id = DUBBO_PROPERTIES_ENDPOINT_ID) +@Endpoint(id = "dubboProperties") public class DubboPropertiesEndpoint extends AbstractDubboEndpoint { @ReadOperation diff --git a/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboReferencesMetadataEndpoint.java b/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboReferencesMetadataEndpoint.java index 649b06614..8a712c6f1 100644 --- a/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboReferencesMetadataEndpoint.java +++ b/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboReferencesMetadataEndpoint.java @@ -19,6 +19,7 @@ import com.alibaba.dubbo.config.annotation.Reference; import com.alibaba.dubbo.config.spring.ReferenceBean; import com.alibaba.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor; + import org.springframework.beans.factory.annotation.InjectionMetadata; import org.springframework.boot.actuate.endpoint.annotation.Endpoint; import org.springframework.boot.actuate.endpoint.annotation.ReadOperation; @@ -32,7 +33,7 @@ * @author Mercy * @since 1.0.0 */ -@Endpoint(id = "dubbo-references") +@Endpoint(id = "dubboReferences") public class DubboReferencesMetadataEndpoint extends AbstractDubboEndpoint { @ReadOperation diff --git a/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboServicesMetadataEndpoint.java b/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboServicesMetadataEndpoint.java index 4b36484d8..3b1c5cb52 100644 --- a/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboServicesMetadataEndpoint.java +++ b/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboServicesMetadataEndpoint.java @@ -18,6 +18,7 @@ import com.alibaba.dubbo.config.annotation.Service; import com.alibaba.dubbo.config.spring.ServiceBean; + import org.springframework.boot.actuate.endpoint.annotation.Endpoint; import org.springframework.boot.actuate.endpoint.annotation.ReadOperation; @@ -30,7 +31,7 @@ * @author Mercy * @since 0.2.0 */ -@Endpoint(id = "dubbo-services") +@Endpoint(id = "dubboServices") public class DubboServicesMetadataEndpoint extends AbstractDubboEndpoint { @ReadOperation diff --git a/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboShutdownEndpoint.java b/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboShutdownEndpoint.java index 9ad9e833f..6c6e26a8c 100644 --- a/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboShutdownEndpoint.java +++ b/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboShutdownEndpoint.java @@ -19,6 +19,7 @@ import com.alibaba.dubbo.config.ProtocolConfig; import com.alibaba.dubbo.config.spring.ServiceBean; import com.alibaba.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor; + import org.springframework.boot.actuate.endpoint.annotation.Endpoint; import org.springframework.boot.actuate.endpoint.annotation.WriteOperation; @@ -34,7 +35,7 @@ * @author Mercy * @since 0.2.0 */ -@Endpoint(id = "dubbo-shutdown") +@Endpoint(id = "dubboShutdown") public class DubboShutdownEndpoint extends AbstractDubboEndpoint { diff --git a/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/health/DubboHealthIndicatorProperties.java b/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/health/DubboHealthIndicatorProperties.java index bd35ed996..2ba7da2db 100644 --- a/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/health/DubboHealthIndicatorProperties.java +++ b/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/health/DubboHealthIndicatorProperties.java @@ -17,6 +17,7 @@ package com.alibaba.boot.dubbo.actuate.health; import com.alibaba.dubbo.common.status.StatusChecker; + import org.springframework.boot.actuate.health.HealthIndicator; import org.springframework.boot.context.properties.ConfigurationProperties; @@ -53,7 +54,6 @@ public void setStatus(Status status) { /** * The nested class for {@link StatusChecker}'s names - *

*

      * registry=com.alibaba.dubbo.registry.status.RegistryStatusChecker
      * spring=com.alibaba.dubbo.config.spring.status.SpringStatusChecker
diff --git a/dubbo-spring-boot-actuator/src/main/resources/META-INF/dubbo-endpoins-default.properties b/dubbo-spring-boot-actuator/src/main/resources/META-INF/dubbo-endpoins-default.properties
index 97a012feb..99215bfcd 100644
--- a/dubbo-spring-boot-actuator/src/main/resources/META-INF/dubbo-endpoins-default.properties
+++ b/dubbo-spring-boot-actuator/src/main/resources/META-INF/dubbo-endpoins-default.properties
@@ -4,19 +4,19 @@
 
 # Set enabled for Dubbo Endpoints
 management.endpoint.dubbo.enabled = true
-management.endpoint.dubbo-shutdown.enabled = false
-management.endpoint.dubbo-configs.enabled = true
-management.endpoint.dubbo-services.enabled = false
-management.endpoint.dubbo-references.enabled = false
-management.endpoint.dubbo-properties.enabled = true
+management.endpoint.dubboShutdown.enabled = false
+management.endpoint.dubboConfigs.enabled = true
+management.endpoint.dubboServices.enabled = false
+management.endpoint.dubboReferences.enabled = false
+management.endpoint.dubboProperties.enabled = true
 
 # "management.endpoints.web.base-path" should not be configured in this file
 
 # Re-defines path-mapping of Dubbo Web Endpoints
-management.endpoints.web.path-mapping.dubbo-shutdown = dubbo/shutdown
-management.endpoints.web.path-mapping.dubbo-configs = dubbo/configs
-management.endpoints.web.path-mapping.dubbo-services = dubbo/services
-management.endpoints.web.path-mapping.dubbo-references = dubbo/references
-management.endpoints.web.path-mapping.dubbo-properties = dubbo/properties
+management.endpoints.web.path-mapping.dubboShutdown = dubbo/shutdown
+management.endpoints.web.path-mapping.dubboConfigs = dubbo/configs
+management.endpoints.web.path-mapping.dubboServices = dubbo/services
+management.endpoints.web.path-mapping.dubboReferences = dubbo/references
+management.endpoints.web.path-mapping.dubboProperties = dubbo/properties
 
 
diff --git a/dubbo-spring-boot-actuator/src/test/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboEndpointTest.java b/dubbo-spring-boot-actuator/src/test/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboEndpointTest.java
index 0135ec331..e1aa531f0 100644
--- a/dubbo-spring-boot-actuator/src/test/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboEndpointTest.java
+++ b/dubbo-spring-boot-actuator/src/test/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboEndpointTest.java
@@ -17,12 +17,12 @@
 package com.alibaba.boot.dubbo.actuate.endpoint;
 
 import com.alibaba.boot.dubbo.util.DubboUtils;
+
 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.SpringJUnit4ClassRunner;
 import org.springframework.test.context.junit4.SpringRunner;
 
 import java.util.Map;
diff --git a/dubbo-spring-boot-actuator/src/test/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboEndpointsAutoConfigurationTest.java b/dubbo-spring-boot-actuator/src/test/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboEndpointsAutoConfigurationTest.java
index 9bd190be1..3576dbafe 100644
--- a/dubbo-spring-boot-actuator/src/test/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboEndpointsAutoConfigurationTest.java
+++ b/dubbo-spring-boot-actuator/src/test/java/com/alibaba/boot/dubbo/actuate/endpoint/DubboEndpointsAutoConfigurationTest.java
@@ -18,6 +18,7 @@
 
 import com.alibaba.boot.dubbo.actuate.autoconfigure.DubboEndpointsAutoConfiguration;
 import com.alibaba.dubbo.config.annotation.Service;
+
 import org.junit.Assert;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -57,11 +58,11 @@
                 "dubbo.provider.host=127.0.0.1",
                 "dubbo.scan.basePackages=com.alibaba.boot.dubbo.actuate.endpoint",
                 "management.endpoint.dubbo.enabled = true",
-                "management.endpoint.dubbo-shutdown.enabled = true",
-                "management.endpoint.dubbo-configs.enabled = true",
-                "management.endpoint.dubbo-services.enabled = true",
-                "management.endpoint.dubbo-references.enabled = true",
-                "management.endpoint.dubbo-properties.enabled = true",
+                "management.endpoint.dubboShutdown.enabled = true",
+                "management.endpoint.dubboConfigs.enabled = true",
+                "management.endpoint.dubboServices.enabled = true",
+                "management.endpoint.dubboReferences.enabled = true",
+                "management.endpoint.dubboProperties.enabled = true",
         })
 @EnableAutoConfiguration
 public class DubboEndpointsAutoConfigurationTest {
@@ -143,7 +144,7 @@ public void testServices() {
 
         Assert.assertEquals(1, services.size());
 
-        Map demoServiceMeta = services.get("ServiceBean:dubboEndpointsAutoConfigurationTest.DefaultDemoService:com.alibaba.boot.dubbo.actuate.endpoint.DubboEndpointsAutoConfigurationTest$DemoService:${dubbo.service.version}");
+        Map demoServiceMeta = services.get("ServiceBean:com.alibaba.boot.dubbo.actuate.endpoint.DubboEndpointsAutoConfigurationTest$DemoService:1.0.0");
 
         Assert.assertEquals("1.0.0", demoServiceMeta.get("version"));
 
diff --git a/dubbo-spring-boot-autoconfigure/README.md b/dubbo-spring-boot-autoconfigure/README.md
index b5e9306ff..d75b8a1f4 100644
--- a/dubbo-spring-boot-autoconfigure/README.md
+++ b/dubbo-spring-boot-autoconfigure/README.md
@@ -23,7 +23,7 @@ You can introduce the latest `dubbo-spring-boot-autoconfigure` to your project
 
     com.alibaba.boot
     dubbo-spring-boot-autoconfigure
-    0.2.0
+    0.2.1-SNAPSHOT
 
 ```
 
diff --git a/dubbo-spring-boot-autoconfigure/pom.xml b/dubbo-spring-boot-autoconfigure/pom.xml
index 1e892fa1c..ae2bae3fd 100644
--- a/dubbo-spring-boot-autoconfigure/pom.xml
+++ b/dubbo-spring-boot-autoconfigure/pom.xml
@@ -38,6 +38,7 @@
             spring-boot-autoconfigure
             true
         
+
         
             org.springframework.boot
             spring-boot-starter-logging
@@ -58,11 +59,18 @@
             true
         
 
+        
+        
+            com.alibaba.spring
+            spring-context-support
+        
+
         
         
             org.springframework.boot
             spring-boot-starter-test
             test
         
+
     
 
\ No newline at end of file
diff --git a/dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/autoconfigure/RelaxedDubboConfigBinder.java b/dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/autoconfigure/RelaxedDubboConfigBinder.java
index def20f000..51a6ab72f 100644
--- a/dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/autoconfigure/RelaxedDubboConfigBinder.java
+++ b/dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/autoconfigure/RelaxedDubboConfigBinder.java
@@ -19,13 +19,16 @@
 import com.alibaba.dubbo.config.AbstractConfig;
 import com.alibaba.dubbo.config.spring.context.properties.AbstractDubboConfigBinder;
 import com.alibaba.dubbo.config.spring.context.properties.DubboConfigBinder;
+
 import org.springframework.boot.context.properties.bind.BindHandler;
 import org.springframework.boot.context.properties.bind.Bindable;
 import org.springframework.boot.context.properties.bind.Binder;
+import org.springframework.boot.context.properties.bind.PropertySourcesPlaceholdersResolver;
 import org.springframework.boot.context.properties.bind.handler.IgnoreErrorsBindHandler;
 import org.springframework.boot.context.properties.bind.handler.NoUnboundElementsBindHandler;
 import org.springframework.boot.context.properties.source.ConfigurationPropertySource;
 import org.springframework.boot.context.properties.source.UnboundElementsSourceFilter;
+import org.springframework.core.env.PropertySource;
 
 import static org.springframework.boot.context.properties.source.ConfigurationPropertySources.from;
 
@@ -41,13 +44,15 @@ public class RelaxedDubboConfigBinder extends AbstractDubboConfigBinder {
     @Override
     public  void bind(String prefix, C dubboConfig) {
 
+        Iterable> propertySources = getPropertySources();
+
         // Converts ConfigurationPropertySources
-        Iterable propertySources = from(getPropertySources());
+        Iterable configurationPropertySources = from(propertySources);
 
         // Wrap Bindable from DubboConfig instance
         Bindable bindable = Bindable.ofInstance(dubboConfig);
 
-        Binder binder = new Binder(propertySources);
+        Binder binder = new Binder(configurationPropertySources, new PropertySourcesPlaceholdersResolver(propertySources));
 
         // Get BindHandler
         BindHandler bindHandler = getBindHandler();
diff --git a/dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/context/event/WelcomeLogoApplicationListener.java b/dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/context/event/WelcomeLogoApplicationListener.java
index ae9682c81..99cf9808a 100644
--- a/dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/context/event/WelcomeLogoApplicationListener.java
+++ b/dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/context/event/WelcomeLogoApplicationListener.java
@@ -17,6 +17,7 @@
 package com.alibaba.boot.dubbo.context.event;
 
 import com.alibaba.dubbo.common.Version;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent;
@@ -24,8 +25,12 @@
 import org.springframework.context.ApplicationListener;
 import org.springframework.core.annotation.Order;
 
-import static com.alibaba.boot.dubbo.util.DubboUtils.*;
-import static com.alibaba.dubbo.qos.server.DubboLogo.dubbo;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import static com.alibaba.boot.dubbo.util.DubboUtils.DUBBO_GITHUB_URL;
+import static com.alibaba.boot.dubbo.util.DubboUtils.DUBBO_MAILING_LIST;
+import static com.alibaba.boot.dubbo.util.DubboUtils.DUBBO_SPRING_BOOT_GITHUB_URL;
+import static com.alibaba.boot.dubbo.util.DubboUtils.LINE_SEPARATOR;
 
 /**
  * Dubbo Welcome Logo {@link ApplicationListener}
@@ -37,10 +42,16 @@
 @Order(LoggingApplicationListener.DEFAULT_ORDER + 1)
 public class WelcomeLogoApplicationListener implements ApplicationListener {
 
+    private static AtomicBoolean processed = new AtomicBoolean(false);
 
     @Override
     public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) {
 
+        // Skip if processed before, prevent duplicated execution in Hierarchical ApplicationContext
+        if (processed.get()) {
+            return;
+        }
+
         /**
          * Gets Logger After LoggingSystem configuration ready
          * @see LoggingApplicationListener
@@ -55,9 +66,10 @@ public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) {
             System.out.print(bannerText);
         }
 
+        // mark processed to be true
+        processed.compareAndSet(false, true);
     }
 
-
     String buildBannerText() {
 
         StringBuilder bannerTextBuilder = new StringBuilder();
@@ -71,7 +83,7 @@ String buildBannerText() {
                 .append(" :: Dubbo (v").append(Version.getVersion()).append(") : ")
                 .append(DUBBO_GITHUB_URL)
                 .append(LINE_SEPARATOR)
-                .append(" :: Google group : ")
+                .append(" :: Discuss group : ")
                 .append(DUBBO_MAILING_LIST)
                 .append(LINE_SEPARATOR)
         ;
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
new file mode 100644
index 000000000..d8a671b95
--- /dev/null
+++ b/dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/env/DubboDefaultPropertiesEnvironmentPostProcessor.java
@@ -0,0 +1,122 @@
+/*
+ * 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.env;
+
+import com.alibaba.dubbo.config.ApplicationConfig;
+import com.alibaba.dubbo.config.spring.context.annotation.EnableDubboConfig;
+import com.alibaba.dubbo.config.spring.context.annotation.EnableDubboConfigBinding;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.context.ContextIdApplicationContextInitializer;
+import org.springframework.boot.env.EnvironmentPostProcessor;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.core.Ordered;
+import org.springframework.core.env.ConfigurableEnvironment;
+import org.springframework.core.env.Environment;
+import org.springframework.core.env.MapPropertySource;
+import org.springframework.core.env.MutablePropertySources;
+import org.springframework.core.env.PropertySource;
+import org.springframework.util.CollectionUtils;
+import org.springframework.util.StringUtils;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * The lowest precedence {@link EnvironmentPostProcessor} processes
+ * {@link SpringApplication#setDefaultProperties(Properties) Spring Boot default properties} for Dubbo
+ * as late as possible before {@link ConfigurableApplicationContext#refresh() application context refresh}.
+ */
+public class DubboDefaultPropertiesEnvironmentPostProcessor implements EnvironmentPostProcessor, Ordered {
+
+    /**
+     * The name of default {@link PropertySource} defined in SpringApplication#configurePropertySources method.
+     */
+    private static final String PROPERTY_SOURCE_NAME = "defaultProperties";
+
+    /**
+     * The property name of Spring Application
+     *
+     * @see ContextIdApplicationContextInitializer
+     */
+    private static final String SPRING_APPLICATION_NAME_PROPERTY = "spring.application.name";
+
+    /**
+     * The property name of {@link ApplicationConfig}
+     *
+     * @see EnableDubboConfig
+     * @see EnableDubboConfigBinding
+     */
+    private static final String DUBBO_APPLICATION_NAME_PROPERTY = "dubbo.application.name";
+
+    @Override
+    public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
+        MutablePropertySources propertySources = environment.getPropertySources();
+        Map defaultProperties = createDefaultProperties(environment);
+        if (!CollectionUtils.isEmpty(defaultProperties)) {
+            addOrReplace(propertySources, defaultProperties);
+        }
+    }
+
+    @Override
+    public int getOrder() {
+        return LOWEST_PRECEDENCE;
+    }
+
+    private Map createDefaultProperties(ConfigurableEnvironment environment) {
+        Map defaultProperties = new HashMap();
+        setDubboApplicationNameProperty(environment, defaultProperties);
+        return defaultProperties;
+    }
+
+    private void setDubboApplicationNameProperty(Environment environment, Map defaultProperties) {
+        String springApplicationName = environment.getProperty(SPRING_APPLICATION_NAME_PROPERTY);
+        if (StringUtils.hasLength(springApplicationName)
+                && !environment.containsProperty(DUBBO_APPLICATION_NAME_PROPERTY)) {
+            defaultProperties.put(DUBBO_APPLICATION_NAME_PROPERTY, springApplicationName);
+        }
+    }
+
+    /**
+     * Copy from BusEnvironmentPostProcessor#addOrReplace(MutablePropertySources, Map)
+     *
+     * @param propertySources {@link MutablePropertySources}
+     * @param map             Default Dubbo Properties
+     */
+    private void addOrReplace(MutablePropertySources propertySources,
+                              Map map) {
+        MapPropertySource target = null;
+        if (propertySources.contains(PROPERTY_SOURCE_NAME)) {
+            PropertySource source = propertySources.get(PROPERTY_SOURCE_NAME);
+            if (source instanceof MapPropertySource) {
+                target = (MapPropertySource) source;
+                for (String key : map.keySet()) {
+                    if (!target.containsProperty(key)) {
+                        target.getSource().put(key, map.get(key));
+                    }
+                }
+            }
+        }
+        if (target == null) {
+            target = new MapPropertySource(PROPERTY_SOURCE_NAME, map);
+        }
+        if (!propertySources.contains(PROPERTY_SOURCE_NAME)) {
+            propertySources.addLast(target);
+        }
+    }
+}
\ No newline at end of file
diff --git a/dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/util/DubboUtils.java b/dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/util/DubboUtils.java
index edf4ab2cb..7bf2b6966 100644
--- a/dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/util/DubboUtils.java
+++ b/dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/util/DubboUtils.java
@@ -16,11 +16,12 @@
  */
 package com.alibaba.boot.dubbo.util;
 
+import org.springframework.core.env.ConfigurableEnvironment;
+
 import java.util.Collections;
 import java.util.Map;
 import java.util.SortedMap;
 import java.util.TreeMap;
-import org.springframework.core.env.ConfigurableEnvironment;
 
 /**
  * The utilities class for Dubbo
@@ -61,7 +62,7 @@ public abstract class DubboUtils {
      * 

* The default value is empty set. */ - public static final String BASE_PACKAGES_PROPERTY_NAME = DUBBO_SCAN_PREFIX + PROPERTY_NAME_SEPARATOR + "basePackages"; + public static final String BASE_PACKAGES_PROPERTY_NAME = DUBBO_SCAN_PREFIX + PROPERTY_NAME_SEPARATOR + "base-packages"; /** * The property name of multiple properties binding from externalized configuration diff --git a/dubbo-spring-boot-autoconfigure/src/main/resources/META-INF/spring-configuration-metadata.json b/dubbo-spring-boot-autoconfigure/src/main/resources/META-INF/spring-configuration-metadata.json index 078dae99d..7ce2ceec9 100644 --- a/dubbo-spring-boot-autoconfigure/src/main/resources/META-INF/spring-configuration-metadata.json +++ b/dubbo-spring-boot-autoconfigure/src/main/resources/META-INF/spring-configuration-metadata.json @@ -1090,8 +1090,8 @@ }, { "sourceType": "com.alibaba.boot.dubbo.autoconfigure.DubboScanProperties", - "name": "dubbo.scan.basePackages", - "description": "The basePackages to scan , the multiple-value is delimited by comma\n\n @see EnableDubbo#scanBasePackages()", + "name": "dubbo.scan.base-packages", + "description": "The base-packages to scan , the multiple-value is delimited by comma\n\n @see EnableDubbo#scanBasePackages()", "type": "java.util.Set" } ] diff --git a/dubbo-spring-boot-autoconfigure/src/main/resources/META-INF/spring.factories b/dubbo-spring-boot-autoconfigure/src/main/resources/META-INF/spring.factories index 52fe93ce2..4ea2a1a98 100644 --- a/dubbo-spring-boot-autoconfigure/src/main/resources/META-INF/spring.factories +++ b/dubbo-spring-boot-autoconfigure/src/main/resources/META-INF/spring.factories @@ -5,4 +5,7 @@ com.alibaba.boot.dubbo.autoconfigure.DubboAutoConfiguration org.springframework.context.ApplicationListener=\ com.alibaba.boot.dubbo.context.event.OverrideDubboConfigApplicationListener,\ com.alibaba.boot.dubbo.context.event.WelcomeLogoApplicationListener,\ -com.alibaba.boot.dubbo.context.event.AwaitingNonWebApplicationListener \ No newline at end of file +com.alibaba.boot.dubbo.context.event.AwaitingNonWebApplicationListener + +org.springframework.boot.env.EnvironmentPostProcessor=\ +com.alibaba.boot.dubbo.env.DubboDefaultPropertiesEnvironmentPostProcessor \ No newline at end of file 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 new file mode 100644 index 000000000..626f2c9c6 --- /dev/null +++ b/dubbo-spring-boot-autoconfigure/src/test/java/com/alibaba/boot/dubbo/env/DubboDefaultPropertiesEnvironmentPostProcessorTest.java @@ -0,0 +1,85 @@ +/* + * 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.env; + +import org.junit.Assert; +import org.junit.Test; +import org.springframework.boot.SpringApplication; +import org.springframework.core.Ordered; +import org.springframework.core.env.MapPropertySource; +import org.springframework.core.env.MutablePropertySources; +import org.springframework.core.env.PropertySource; +import org.springframework.mock.env.MockEnvironment; + +import java.util.HashMap; + +/** + * {@link DubboDefaultPropertiesEnvironmentPostProcessor} Test + */ +public class DubboDefaultPropertiesEnvironmentPostProcessorTest { + + private DubboDefaultPropertiesEnvironmentPostProcessor instance = + new DubboDefaultPropertiesEnvironmentPostProcessor(); + + private SpringApplication springApplication = new SpringApplication(); + + @Test + public void testOrder() { + Assert.assertEquals(Ordered.LOWEST_PRECEDENCE, instance.getOrder()); + } + + @Test + public void testPostProcessEnvironment() { + MockEnvironment environment = new MockEnvironment(); + // Case 1 : Not Any property + instance.postProcessEnvironment(environment, springApplication); + // Get PropertySources + MutablePropertySources propertySources = environment.getPropertySources(); + // Nothing to change + PropertySource defaultPropertySource = propertySources.get("defaultProperties"); + Assert.assertNull(defaultPropertySource); + + // Case 2 : Only set property "spring.application.name" + environment.setProperty("spring.application.name", "demo-dubbo-application"); + instance.postProcessEnvironment(environment, springApplication); + defaultPropertySource = propertySources.get("defaultProperties"); + Object dubboApplicationName = defaultPropertySource.getProperty("dubbo.application.name"); + Assert.assertEquals("demo-dubbo-application", dubboApplicationName); + + // Case 3 : Only set property "dubbo.application.name" + // Rest environment + environment = new MockEnvironment(); + propertySources = environment.getPropertySources(); + environment.setProperty("dubbo.application.name", "demo-dubbo-application"); + instance.postProcessEnvironment(environment, springApplication); + defaultPropertySource = propertySources.get("defaultProperties"); + Assert.assertNull(defaultPropertySource); + dubboApplicationName = environment.getProperty("dubbo.application.name"); + Assert.assertEquals("demo-dubbo-application", dubboApplicationName); + + // Case 4 : If "defaultProperties" PropertySource is present in PropertySources + // Rest environment + environment = new MockEnvironment(); + propertySources = environment.getPropertySources(); + propertySources.addLast(new MapPropertySource("defaultProperties", new HashMap())); + environment.setProperty("spring.application.name", "demo-dubbo-application"); + instance.postProcessEnvironment(environment, springApplication); + defaultPropertySource = propertySources.get("defaultProperties"); + dubboApplicationName = defaultPropertySource.getProperty("dubbo.application.name"); + Assert.assertEquals("demo-dubbo-application", dubboApplicationName); + } +} diff --git a/dubbo-spring-boot-autoconfigure/src/test/java/com/alibaba/boot/dubbo/util/DubboUtilsTest.java b/dubbo-spring-boot-autoconfigure/src/test/java/com/alibaba/boot/dubbo/util/DubboUtilsTest.java index 94df5d0e1..af961134e 100644 --- a/dubbo-spring-boot-autoconfigure/src/test/java/com/alibaba/boot/dubbo/util/DubboUtilsTest.java +++ b/dubbo-spring-boot-autoconfigure/src/test/java/com/alibaba/boot/dubbo/util/DubboUtilsTest.java @@ -22,7 +22,20 @@ import java.util.SortedMap; -import static com.alibaba.boot.dubbo.util.DubboUtils.*; +import static com.alibaba.boot.dubbo.util.DubboUtils.BASE_PACKAGES_PROPERTY_NAME; +import static com.alibaba.boot.dubbo.util.DubboUtils.DEFAULT_MULTIPLE_CONFIG_PROPERTY_VALUE; +import static com.alibaba.boot.dubbo.util.DubboUtils.DEFAULT_OVERRIDE_CONFIG_PROPERTY_VALUE; +import static com.alibaba.boot.dubbo.util.DubboUtils.DUBBO_CONFIG_PREFIX; +import static com.alibaba.boot.dubbo.util.DubboUtils.DUBBO_GITHUB_URL; +import static com.alibaba.boot.dubbo.util.DubboUtils.DUBBO_MAILING_LIST; +import static com.alibaba.boot.dubbo.util.DubboUtils.DUBBO_PREFIX; +import static com.alibaba.boot.dubbo.util.DubboUtils.DUBBO_SCAN_PREFIX; +import static com.alibaba.boot.dubbo.util.DubboUtils.DUBBO_SPRING_BOOT_GITHUB_URL; +import static com.alibaba.boot.dubbo.util.DubboUtils.DUBBO_SPRING_BOOT_GIT_URL; +import static com.alibaba.boot.dubbo.util.DubboUtils.DUBBO_SPRING_BOOT_ISSUES_URL; +import static com.alibaba.boot.dubbo.util.DubboUtils.MULTIPLE_CONFIG_PROPERTY_NAME; +import static com.alibaba.boot.dubbo.util.DubboUtils.OVERRIDE_CONFIG_PROPERTY_NAME; +import static com.alibaba.boot.dubbo.util.DubboUtils.filterDubboProperties; /** * {@link DubboUtils} Test @@ -40,7 +53,7 @@ public void testConstants() { Assert.assertEquals("dubbo.scan", DUBBO_SCAN_PREFIX); - Assert.assertEquals("dubbo.scan.basePackages", BASE_PACKAGES_PROPERTY_NAME); + Assert.assertEquals("dubbo.scan.base-packages", BASE_PACKAGES_PROPERTY_NAME); Assert.assertEquals("dubbo.config", DUBBO_CONFIG_PREFIX); diff --git a/dubbo-spring-boot-parent/pom.xml b/dubbo-spring-boot-parent/pom.xml index b22a36d4b..82ab7009e 100644 --- a/dubbo-spring-boot-parent/pom.xml +++ b/dubbo-spring-boot-parent/pom.xml @@ -37,8 +37,8 @@ 1.8 UTF-8 UTF-8 - 2.0.3.RELEASE - 2.6.2 + 2.1.1.RELEASE + 2.6.5 0.2 3.4.9 2.12.0 @@ -57,6 +57,7 @@ 0.12 2.5.3 2.19.1 + 1.0.2 @@ -92,6 +93,13 @@ + + + com.alibaba.spring + spring-context-support + ${alibaba-spring-context-support.version} + + org.apache.zookeeper @@ -416,6 +424,8 @@ **/*.fc **/*.javascript **/*.properties + **/*.yml + **/*.yaml **/*.thrift **/*.sh **/*.bat diff --git a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-consumer/pom.xml b/dubbo-spring-boot-samples/dubbo-spring-boot-sample-consumer/pom.xml index dec0ef069..962dea625 100644 --- a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-consumer/pom.xml +++ b/dubbo-spring-boot-samples/dubbo-spring-boot-sample-consumer/pom.xml @@ -53,6 +53,11 @@ ${project.version} + + com.alibaba + dubbo + + ${project.groupId} dubbo-spring-boot-sample-api 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/dubbo-spring-boot-sample-consumer/src/main/java/com/alibaba/boot/dubbo/demo/consumer/bootstrap/DubboConsumerDemo.java index 705101ae5..7f10d51ea 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/dubbo-spring-boot-sample-consumer/src/main/java/com/alibaba/boot/dubbo/demo/consumer/bootstrap/DubboConsumerDemo.java @@ -17,8 +17,9 @@ package com.alibaba.boot.dubbo.demo.consumer.bootstrap; import com.alibaba.boot.dubbo.demo.consumer.controller.DemoConsumerController; -import org.springframework.boot.SpringApplication; + import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.builder.SpringApplicationBuilder; /** * Dubbo Consumer Demo @@ -31,9 +32,8 @@ public class DubboConsumerDemo { public static void main(String[] args) { - - SpringApplication.run(DubboConsumerDemo.class,args); - + new SpringApplicationBuilder(DubboConsumerDemo.class) + .profiles("prod") + .run(args); } - } 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-spring-boot-sample-consumer/src/main/java/com/alibaba/boot/dubbo/demo/consumer/controller/DemoConsumerController.java index 1897979a4..99cb0fc1b 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-spring-boot-sample-consumer/src/main/java/com/alibaba/boot/dubbo/demo/consumer/controller/DemoConsumerController.java @@ -15,8 +15,10 @@ * limitations under the License. */ package com.alibaba.boot.dubbo.demo.consumer.controller; + import com.alibaba.boot.dubbo.demo.consumer.DemoService; import com.alibaba.dubbo.config.annotation.Reference; + import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; @@ -31,8 +33,8 @@ @RestController public class DemoConsumerController { - @Reference(version = "${demo.service.version}", - application = "${dubbo.application.id}", + @Reference( + version = "${demo.service.version}", url = "dubbo://localhost:12345") private DemoService demoService; diff --git a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-consumer/src/main/resources/application.properties b/dubbo-spring-boot-samples/dubbo-spring-boot-sample-consumer/src/main/resources/application.properties deleted file mode 100644 index df91988c6..000000000 --- a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-consumer/src/main/resources/application.properties +++ /dev/null @@ -1,38 +0,0 @@ -# Spring boot application -spring.application.name = dubbo-consumer-demo -server.port = 8080 -management.server.port = 8081 - -# DemoService service version -demo.service.version = 1.0.0 - -# Dubbo Config properties -## ApplicationConfig Bean -dubbo.application.id = dubbo-consumer-demo -dubbo.application.name = dubbo-consumer-demo - -## Legacy QOS Config -dubbo.qos.port = 22223 - -## ProtocolConfig Bean -dubbo.protocol.id = dubbo -dubbo.protocol.name = dubbo -dubbo.protocol.port = 12345 - -# Dubbo Endpoint (default status is disable) -endpoints.dubbo.enabled = true - -# Dubbo Health -## StatusChecker Name defaults (default : "memory", "load" ) -management.health.dubbo.status.defaults = memory - -# Enables Dubbo All Endpoints -management.endpoint.dubbo.enabled = true -management.endpoint.dubbo-shutdown.enabled = true -management.endpoint.dubbo-configs.enabled = true -management.endpoint.dubbo-services.enabled = true -management.endpoint.dubbo-references.enabled = true -management.endpoint.dubbo-properties.enabled = true - -# Exposes all web endpoints -management.endpoints.web.exposure.include = * \ 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 new file mode 100644 index 000000000..9aad95db6 --- /dev/null +++ b/dubbo-spring-boot-samples/dubbo-spring-boot-sample-consumer/src/main/resources/application.yml @@ -0,0 +1,37 @@ +spring: + application: + name: dubbo-consumer-demo + +server: + port: 8080 + +management: + server: + port: 8081 + +dubbo: + application: + id: ${spring.application.name} + logger: slf4j + protocol: + id: dubbo + name: dubbo + port: 12345 + +--- +spring: + profiles: prod + +endpoints: + dubbo: + enabled: true + +management: + health: + dubbo: + status: + defaults: memory + endpoints: + web: + exposure: + include: "*" \ 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-spring-boot-sample-provider/pom.xml index 1dc600b53..bb4eff8e7 100644 --- a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/pom.xml +++ b/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/pom.xml @@ -26,7 +26,7 @@ 4.0.0 dubbo-spring-boot-sample-provider - Dubbo Spring Boot Sample : Provider + Dubbo Spring Boot Sample : Provider @@ -36,6 +36,30 @@ spring-boot-starter + + org.jboss.resteasy + resteasy-jaxrs + 3.0.19.Final + + + + javax.validation + validation-api + 1.1.0.Final + + + + org.mortbay.jetty + jetty + 6.1.26 + + + org.mortbay.jetty + servlet-api + + + + org.springframework.boot spring-boot-starter-actuator @@ -53,6 +77,11 @@ ${project.version} + + com.alibaba + dubbo + + ${project.groupId} dubbo-spring-boot-sample-api 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-spring-boot-sample-provider/src/main/java/com/alibaba/boot/dubbo/demo/provider/service/DefaultDemoService.java index 48bfc22bf..eda8d4127 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-spring-boot-sample-provider/src/main/java/com/alibaba/boot/dubbo/demo/provider/service/DefaultDemoService.java @@ -19,6 +19,10 @@ import com.alibaba.boot.dubbo.demo.consumer.DemoService; import com.alibaba.dubbo.config.annotation.Service; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.QueryParam; + /** * Default {@link DemoService} * @@ -28,14 +32,15 @@ */ @Service( version = "${demo.service.version}", - application = "${dubbo.application.id}", - protocol = "${dubbo.protocol.id}", + protocol = {"dubbo", "rest"}, registry = "${dubbo.registry.id}" ) +@Path("demo") public class DefaultDemoService implements DemoService { - public String sayHello(String name) { + @GET + @Path("/say-hello") + public String sayHello(@QueryParam("name") String name) { return "Hello, " + name + " (from Spring Boot)"; } - } \ 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 index 323f72e43..b6f2c3a3e 100644 --- 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 @@ -7,21 +7,25 @@ server.port = 9090 demo.service.version = 1.0.0 # Base packages to scan Dubbo Component: @com.alibaba.dubbo.config.annotation.Service -dubbo.scan.basePackages = com.alibaba.boot.dubbo.demo.provider.service +dubbo.scan.base-packages = com.alibaba.boot.dubbo.demo.provider.service # Dubbo Config properties ## ApplicationConfig Bean -dubbo.application.id = dubbo-provider-demo -dubbo.application.name = dubbo-provider-demo -dubbo.application.qos.port=22222 +dubbo.application.qos.port=0 dubbo.application.qos.enable=true + +## Enable multiple config bindings +dubbo.config.multiple =true + ## ProtocolConfig Bean -dubbo.protocol.id = dubbo -dubbo.protocol.name = dubbo -dubbo.protocol.port = 12345 -dubbo.protocol.status = server +dubbo.protocols.dubbo.name = dubbo +dubbo.protocols.dubbo.port = 12345 +dubbo.protocols.dubbo.status = server + +dubbo.protocols.rest.name = rest +dubbo.protocols.rest.port = 8888 ## RegistryConfig Bean dubbo.registry.id = my-registry @@ -29,11 +33,11 @@ dubbo.registry.address = N/A # Enables Dubbo All Endpoints management.endpoint.dubbo.enabled = true -management.endpoint.dubbo-shutdown.enabled = true -management.endpoint.dubbo-configs.enabled = true -management.endpoint.dubbo-services.enabled = true -management.endpoint.dubbo-references.enabled = true -management.endpoint.dubbo-properties.enabled = true +management.endpoint.dubboShutdown.enabled = true +management.endpoint.dubboConfigs.enabled = true +management.endpoint.dubboServices.enabled = true +management.endpoint.dubboReferences.enabled = true +management.endpoint.dubboProperties.enabled = true # Dubbo Health ## StatusChecker Name defaults (default : "memory", "load" ) diff --git a/dubbo-spring-boot-starter/pom.xml b/dubbo-spring-boot-starter/pom.xml index 993366029..f5e7dafed 100644 --- a/dubbo-spring-boot-starter/pom.xml +++ b/dubbo-spring-boot-starter/pom.xml @@ -36,24 +36,20 @@ org.springframework.boot spring-boot-starter - provided - - - - - com.alibaba - dubbo + true org.apache.zookeeper zookeeper + true org.apache.curator curator-framework + true