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/11/08 05:15:43 UTC
[dubbo-spring-boot-project] branch 0.2.x updated: Config Dubbo
Properties Like SpringBoot: ${property_name:default_value} (#512)
This is an automated email from the ASF dual-hosted git repository.
mercyblitz pushed a commit to branch 0.2.x
in repository https://gitbox.apache.org/repos/asf/dubbo-spring-boot-project.git
The following commit(s) were added to refs/heads/0.2.x by this push:
new 6776542 Config Dubbo Properties Like SpringBoot: ${property_name:default_value} (#512)
6776542 is described below
commit 6776542f62cc20ea36c928ef723240a7ceadde59
Author: zhongdongyue <zh...@gmail.com>
AuthorDate: Fri Nov 8 13:15:38 2019 +0800
Config Dubbo Properties Like SpringBoot: ${property_name:default_value} (#512)
---
.../src/main/java/com/alibaba/boot/dubbo/util/DubboUtils.java | 5 ++++-
.../src/main/java/com/alibaba/boot/dubbo/util/EnvironmentUtils.java | 3 ++-
pom.xml | 2 +-
3 files changed, 7 insertions(+), 3 deletions(-)
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 59cde99..5973084 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,6 +16,7 @@
*/
package com.alibaba.boot.dubbo.util;
+import org.springframework.boot.context.properties.bind.PropertySourcesPlaceholdersResolver;
import org.springframework.core.env.ConfigurableEnvironment;
import java.util.Collections;
@@ -123,6 +124,8 @@ public abstract class DubboUtils {
SortedMap<String, Object> dubboProperties = new TreeMap<>();
+ PropertySourcesPlaceholdersResolver resolver = new PropertySourcesPlaceholdersResolver(environment);
+
Map<String, Object> properties = EnvironmentUtils.extractProperties(environment);
for (Map.Entry<String, Object> entry : properties.entrySet()) {
@@ -130,7 +133,7 @@ public abstract class DubboUtils {
if (propertyName.startsWith(DUBBO_PREFIX + PROPERTY_NAME_SEPARATOR)
&& entry.getValue() != null) {
- dubboProperties.put(propertyName, entry.getValue().toString());
+ dubboProperties.put(propertyName, resolver.resolvePlaceholders(entry.getValue()));
}
}
diff --git a/dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/util/EnvironmentUtils.java b/dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/util/EnvironmentUtils.java
index 9b20c58..bf1ade1 100644
--- a/dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/util/EnvironmentUtils.java
+++ b/dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/util/EnvironmentUtils.java
@@ -64,7 +64,8 @@ public abstract class EnvironmentUtils {
for (PropertySource<?> source : map.values()) {
- if (source instanceof EnumerablePropertySource) {
+ if (source instanceof EnumerablePropertySource
+ && !source.getName().equals("systemEnvironment")) {
EnumerablePropertySource propertySource = (EnumerablePropertySource) source;
diff --git a/pom.xml b/pom.xml
index a223d60..2e74a03 100644
--- a/pom.xml
+++ b/pom.xml
@@ -37,7 +37,7 @@
<properties>
<maven_javadoc_version>3.0.1</maven_javadoc_version>
<maven_surefire_version>2.19.1</maven_surefire_version>
- <revision>0.2.1</revision>
+ <revision>0.2.2</revision>
</properties>
<modules>