diff --git a/README.md b/README.md index 4861640b8..9400c1fb3 100644 --- a/README.md +++ b/README.md @@ -17,24 +17,32 @@ You can introduce the latest `dubbo-spring-boot-starter` to your project by adding the following dependency to your pom.xml ```xml - - com.alibaba.boot - dubbo-spring-boot-starter - 0.1.1 - - - - - com.alibaba - dubbo - 2.6.5 - - - - com.alibaba.spring - spring-context-support - 1.0.2 - + + + ... + + + com.alibaba.boot + dubbo-spring-boot-starter + 0.1.2-SNAPSHOT + + + + + com.alibaba + dubbo + 2.6.5 + + + + com.alibaba.spring + spring-context-support + 1.0.2 + + + ... + + ``` If your project failed to resolve the dependency, try to add the following repository: @@ -60,15 +68,14 @@ If your project failed to resolve the dependency, try to add the following repos If you'd like to attempt to experience latest features, you also can build from source as follow: -1. Maven install [dubbo 2.6.2-SNAPSHOT](https://github.com/apache/incubator-dubbo/tree/2.6.2-release) in your local repository -2. Maven install current project in your local repository. +1. Maven install current project in your local repository. > Maven install = `mvn install` ### Dependencies | versions | Java | Spring Boot | Dubbo | | -------- | ----- | ----------- | ---------- | -| `0.1.1` | 1.7+ | `1.5.x` | `2.6.2` + | +| `0.1.x` | 1.7+ | `1.5.x` | `2.6.x` + | ## Getting Started diff --git a/README_CN.md b/README_CN.md index 01778043a..ea8dfcf74 100644 --- a/README_CN.md +++ b/README_CN.md @@ -18,24 +18,32 @@ 您可以为您的工程引入最新 `dubbo-spring-boot-starter` 的发布,增加以下依赖到工程的 `pom.xml` 文件中: ```xml - - com.alibaba.boot - dubbo-spring-boot-starter - 0.1.1 - - - - - com.alibaba - dubbo - 2.6.5 - - - - com.alibaba.spring - spring-context-support - 1.0.2 - + + + ... + + + com.alibaba.boot + dubbo-spring-boot-starter + 0.1.2-SNAPSHOT + + + + + com.alibaba + dubbo + 2.6.5 + + + + com.alibaba.spring + spring-context-support + 1.0.2 + + + ... + + ``` 如果您的工程遇到了依赖问题, 请尝试添加如下 Maven 参考到工程的 `pom.xml` 文件中: @@ -61,15 +69,14 @@ 如果你需要尝试最新 `dubbo-spring-boot-project` 的特性,您可将当前工程手动 Maven install 到本地 Maven 仓库: -1. Maven install [dubbo 2.6.2-SNAPSHOT](https://github.com/apache/incubator-dubbo/tree/2.6.2-release) -2. Maven install 当前工程 +1. Maven install 当前工程 > Maven install = `mvn install` ### 依赖关系 | 版本 | Java | Spring Boot | Dubbo | | -------- | ----- | ----------------- | ---------- | -| `0.1.1` | 1.7+ | `1.5.x` | `2.6.2`+ | +| `0.1.x` | 1.7+ | `1.5.x` | `2.6.x`+ | diff --git a/dubbo-spring-boot-actuator/README.md b/dubbo-spring-boot-actuator/README.md index 1a67d86d0..2b61aa144 100644 --- a/dubbo-spring-boot-actuator/README.md +++ b/dubbo-spring-boot-actuator/README.md @@ -21,7 +21,7 @@ You can introduce the latest `dubbo-spring-boot-actuator` to your project by ad com.alibaba.boot dubbo-spring-boot-actuator - 0.1.1 + 0.1.2-SNAPSHOT ``` If your project failed to resolve the dependency, try to add the following repository: diff --git a/dubbo-spring-boot-actuator/README_CN.md b/dubbo-spring-boot-actuator/README_CN.md index 2e6400349..9e6780dd5 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.1.1 + 0.1.2-SNAPSHOT com.alibaba.boot dubbo-spring-boot-actuator - 0.1.1 + 0.1.2-SNAPSHOT ... diff --git a/dubbo-spring-boot-actuator/pom.xml b/dubbo-spring-boot-actuator/pom.xml index 079bd07bb..09fff8829 100644 --- a/dubbo-spring-boot-actuator/pom.xml +++ b/dubbo-spring-boot-actuator/pom.xml @@ -13,14 +13,14 @@ 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. - --> +--> dubbo-spring-boot-parent com.alibaba.boot - 0.1.1 + 0.1.2-SNAPSHOT ../dubbo-spring-boot-parent/pom.xml 4.0.0 diff --git a/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/autoconfigure/DubboEndpointAutoConfiguration.java b/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/autoconfigure/DubboEndpointAutoConfiguration.java index 61ff57f0e..b7e6274dc 100644 --- a/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/autoconfigure/DubboEndpointAutoConfiguration.java +++ b/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/autoconfigure/DubboEndpointAutoConfiguration.java @@ -18,6 +18,8 @@ import com.alibaba.boot.dubbo.actuate.endpoint.DubboEndpoint; import com.alibaba.dubbo.config.annotation.Service; + +import org.springframework.boot.actuate.condition.ConditionalOnEnabledEndpoint; import org.springframework.boot.actuate.endpoint.Endpoint; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; @@ -37,6 +39,7 @@ public class DubboEndpointAutoConfiguration { @Bean @ConditionalOnMissingBean + @ConditionalOnEnabledEndpoint(value = "dubbo", enabledByDefault = false) public DubboEndpoint dubboEndpoint() { return new DubboEndpoint(); } diff --git a/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/autoconfigure/DubboMvcEndpointManagementContextConfiguration.java b/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/autoconfigure/DubboMvcEndpointManagementContextConfiguration.java index d2a405c0e..5bbd1f8b1 100644 --- a/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/autoconfigure/DubboMvcEndpointManagementContextConfiguration.java +++ b/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/autoconfigure/DubboMvcEndpointManagementContextConfiguration.java @@ -19,6 +19,7 @@ import com.alibaba.boot.dubbo.actuate.endpoint.DubboEndpoint; import com.alibaba.boot.dubbo.actuate.endpoint.mvc.DubboMvcEndpoint; import com.alibaba.dubbo.config.annotation.Service; + import org.springframework.boot.actuate.autoconfigure.ManagementContextConfiguration; import org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter; import org.springframework.boot.actuate.endpoint.mvc.MvcEndpoint; diff --git a/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/endpoint/mvc/DubboMvcEndpoint.java b/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/endpoint/mvc/DubboMvcEndpoint.java index f11c57546..641452a1e 100644 --- a/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/endpoint/mvc/DubboMvcEndpoint.java +++ b/dubbo-spring-boot-actuator/src/main/java/com/alibaba/boot/dubbo/actuate/endpoint/mvc/DubboMvcEndpoint.java @@ -17,11 +17,22 @@ package com.alibaba.boot.dubbo.actuate.endpoint.mvc; import com.alibaba.boot.dubbo.actuate.endpoint.DubboEndpoint; -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 com.alibaba.dubbo.config.annotation.Reference; import com.alibaba.dubbo.config.spring.ReferenceBean; import com.alibaba.dubbo.config.spring.ServiceBean; import com.alibaba.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeansException; @@ -49,10 +60,20 @@ import java.math.BigDecimal; import java.math.BigInteger; import java.net.URL; -import java.util.*; +import java.util.Collection; +import java.util.Date; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Set; +import java.util.SortedMap; +import java.util.TreeMap; import java.util.concurrent.ConcurrentMap; -import static com.alibaba.boot.dubbo.actuate.endpoint.DubboEndpoint.*; +import static com.alibaba.boot.dubbo.actuate.endpoint.DubboEndpoint.DUBBO_CONFIGS_ENDPOINT_URI; +import static com.alibaba.boot.dubbo.actuate.endpoint.DubboEndpoint.DUBBO_PROPERTIES_ENDPOINT_URI; +import static com.alibaba.boot.dubbo.actuate.endpoint.DubboEndpoint.DUBBO_REFERENCES_ENDPOINT_URI; +import static com.alibaba.boot.dubbo.actuate.endpoint.DubboEndpoint.DUBBO_SERVICES_ENDPOINT_URI; +import static com.alibaba.boot.dubbo.actuate.endpoint.DubboEndpoint.DUBBO_SHUTDOWN_ENDPOINT_URI; import static com.alibaba.boot.dubbo.util.DubboUtils.filterDubboProperties; import static com.alibaba.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor.BEAN_NAME; import static com.alibaba.dubbo.registry.support.AbstractRegistryFactory.getRegistries; @@ -182,8 +203,18 @@ public Map> references() { Map> referencesMetadata = new LinkedHashMap<>(); - Map> injectedElementReferenceBeanMap - = resolveInjectedElementReferenceBeanMap(); + ReferenceAnnotationBeanPostProcessor beanPostProcessor = getReferenceAnnotationBeanPostProcessor(); + + referencesMetadata.putAll(buildReferencesMetadata(beanPostProcessor.getInjectedFieldReferenceBeanMap())); + referencesMetadata.putAll(buildReferencesMetadata(beanPostProcessor.getInjectedMethodReferenceBeanMap())); + + return referencesMetadata; + } + + + private Map> buildReferencesMetadata( + Map> injectedElementReferenceBeanMap) { + Map> referencesMetadata = new LinkedHashMap<>(); for (Map.Entry> entry : injectedElementReferenceBeanMap.entrySet()) { @@ -200,7 +231,6 @@ public Map> references() { } return referencesMetadata; - } @RequestMapping(value = DUBBO_PROPERTIES_ENDPOINT_URI, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @@ -271,7 +301,7 @@ private Map> resolveInjected getFieldValue(processor, "injectionMetadataCache", ConcurrentMap.class); ConcurrentMap> referenceBeansCache = - getFieldValue(processor, "referenceBeansCache", ConcurrentMap.class); + getFieldValue(processor, "referenceBeanCache", ConcurrentMap.class); for (InjectionMetadata metadata : injectionMetadataCache.values()) { 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 9232cbad0..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; diff --git a/dubbo-spring-boot-actuator/src/test/java/com/alibaba/boot/dubbo/actuate/endpoint/mvc/DubboMvcEndpointTest.java b/dubbo-spring-boot-actuator/src/test/java/com/alibaba/boot/dubbo/actuate/endpoint/mvc/DubboMvcEndpointTest.java index 7ad022121..7b242fab0 100644 --- a/dubbo-spring-boot-actuator/src/test/java/com/alibaba/boot/dubbo/actuate/endpoint/mvc/DubboMvcEndpointTest.java +++ b/dubbo-spring-boot-actuator/src/test/java/com/alibaba/boot/dubbo/actuate/endpoint/mvc/DubboMvcEndpointTest.java @@ -19,6 +19,7 @@ import com.alibaba.boot.dubbo.actuate.endpoint.DubboEndpoint; import com.alibaba.boot.dubbo.autoconfigure.DubboAutoConfiguration; import com.alibaba.dubbo.config.annotation.Service; + import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/dubbo-spring-boot-autoconfigure/README.md b/dubbo-spring-boot-autoconfigure/README.md index 9490e7ded..ec39c1db2 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.1.1 + 0.1.2-SNAPSHOT ``` diff --git a/dubbo-spring-boot-autoconfigure/pom.xml b/dubbo-spring-boot-autoconfigure/pom.xml index 2b9542b35..a878a658b 100644 --- a/dubbo-spring-boot-autoconfigure/pom.xml +++ b/dubbo-spring-boot-autoconfigure/pom.xml @@ -13,14 +13,15 @@ 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. - --> +--> com.alibaba.boot dubbo-spring-boot-parent - 0.1.1 + + 0.1.2-SNAPSHOT ../dubbo-spring-boot-parent 4.0.0 @@ -58,10 +59,10 @@ true + com.alibaba.spring spring-context-support - 1.0.2 diff --git a/dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/autoconfigure/DubboAutoConfiguration.java b/dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/autoconfigure/DubboAutoConfiguration.java index f3060b1a8..11ea77783 100644 --- a/dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/autoconfigure/DubboAutoConfiguration.java +++ b/dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/autoconfigure/DubboAutoConfiguration.java @@ -26,6 +26,7 @@ import com.alibaba.dubbo.config.spring.context.annotation.DubboConfigConfiguration; import com.alibaba.dubbo.config.spring.context.annotation.EnableDubbo; import com.alibaba.dubbo.config.spring.context.annotation.EnableDubboConfig; + import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; @@ -38,7 +39,9 @@ import java.util.Set; -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.DUBBO_PREFIX; +import static com.alibaba.boot.dubbo.util.DubboUtils.MULTIPLE_CONFIG_PROPERTY_NAME; import static java.util.Collections.emptySet; import static org.springframework.beans.factory.config.ConfigurableBeanFactory.SCOPE_PROTOTYPE; 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 333d16817..b72b23465 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,6 +19,7 @@ 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.beans.MutablePropertyValues; import org.springframework.boot.bind.RelaxedDataBinder; @@ -41,7 +42,7 @@ public void bind(String prefix, C dubboConfig) { relaxedDataBinder.setIgnoreInvalidFields(isIgnoreInvalidFields()); relaxedDataBinder.setIgnoreUnknownFields(isIgnoreUnknownFields()); // Get properties under specified prefix from PropertySources - Map properties = getSubProperties(this.getPropertySources(), prefix); + Map properties = getSubProperties(getPropertySources(), prefix); // Convert Map to MutablePropertyValues MutablePropertyValues propertyValues = new MutablePropertyValues(properties); // Bind diff --git a/dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/context/event/OverrideDubboConfigApplicationListener.java b/dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/context/event/OverrideDubboConfigApplicationListener.java index 33ac29b3c..e39ea5050 100644 --- a/dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/context/event/OverrideDubboConfigApplicationListener.java +++ b/dubbo-spring-boot-autoconfigure/src/main/java/com/alibaba/boot/dubbo/context/event/OverrideDubboConfigApplicationListener.java @@ -17,7 +17,9 @@ package com.alibaba.boot.dubbo.context.event; import com.alibaba.dubbo.common.utils.ConfigUtils; + import com.alibaba.dubbo.config.AbstractConfig; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent; @@ -28,13 +30,14 @@ import java.util.SortedMap; -import static com.alibaba.boot.dubbo.util.DubboUtils.*; +import static com.alibaba.boot.dubbo.util.DubboUtils.DEFAULT_OVERRIDE_CONFIG_PROPERTY_VALUE; +import static com.alibaba.boot.dubbo.util.DubboUtils.OVERRIDE_CONFIG_PROPERTY_NAME; +import static com.alibaba.boot.dubbo.util.DubboUtils.filterDubboProperties; /** * {@link ApplicationListener} to override the dubbo properties from {@link Environment}into * {@link ConfigUtils#getProperties() Dubbo Config}. * {@link AbstractConfig Dubbo Config} on {@link ApplicationEnvironmentPreparedEvent}. - *

* * @author Mercy * @see ConfigUtils 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 d87b4ba09..ea2b80248 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,10 @@ 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 static com.alibaba.boot.dubbo.util.DubboUtils.DUBBO_GITHUB_URL; +import static com.alibaba.boot.dubbo.util.DubboUtils.DUBBO_GOOGLE_GROUP_URL; +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} 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 c49b36a5f..eef055f85 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 @@ -62,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 @@ -92,27 +92,27 @@ public abstract class DubboUtils { /** * The github URL of Dubbo Spring Boot */ - public static final String DUBBO_SPRING_BOOT_GITHUB_URL = "https://github.com/dubbo/dubbo-spring-boot-project"; + public static final String DUBBO_SPRING_BOOT_GITHUB_URL = "https://github.com/apache/incubator-dubbo-spring-boot-project"; /** * The git URL of Dubbo Spring Boot */ - public static final String DUBBO_SPRING_BOOT_GIT_URL = "https://github.com/dubbo/dubbo-spring-boot-project.git"; + public static final String DUBBO_SPRING_BOOT_GIT_URL = "https://github.com/apache/incubator-dubbo-spring-boot-project.git"; /** * The issues of Dubbo Spring Boot */ - public static final String DUBBO_SPRING_BOOT_ISSUES_URL = "https://github.com/dubbo/dubbo-spring-boot-project/issues"; + public static final String DUBBO_SPRING_BOOT_ISSUES_URL = "https://github.com/apache/incubator-dubbo-spring-boot-project/issues"; /** * The github URL of Dubbo */ - public static final String DUBBO_GITHUB_URL = "https://github.com/alibaba/dubbo"; + public static final String DUBBO_GITHUB_URL = "https://github.com/apache/incubator-dubbo"; /** * The google group URL of Dubbo */ - public static final String DUBBO_GOOGLE_GROUP_URL = "http://groups.google.com/group/dubbo"; + public static final String DUBBO_GOOGLE_GROUP_URL = "dev@dubbo.incubator.apache.org"; /** * Filters Dubbo Properties from {@link ConfigurableEnvironment} 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 new file mode 100644 index 000000000..7ce2ceec9 --- /dev/null +++ b/dubbo-spring-boot-autoconfigure/src/main/resources/META-INF/spring-configuration-metadata.json @@ -0,0 +1,1098 @@ +{ + "hints": [], + "groups": [], + "properties": [ + { + "sourceType": "com.alibaba.dubbo.config.ApplicationConfig", + "name": "dubbo.application.architecture", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ApplicationConfig", + "name": "dubbo.application.compiler", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ApplicationConfig", + "name": "dubbo.application.default", + "type": "java.lang.Boolean" + }, + { + "sourceType": "com.alibaba.dubbo.config.ApplicationConfig", + "name": "dubbo.application.dump-directory", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ApplicationConfig", + "name": "dubbo.application.environment", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ApplicationConfig", + "name": "dubbo.application.id", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ApplicationConfig", + "name": "dubbo.application.logger", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ApplicationConfig", + "name": "dubbo.application.monitor", + "type": "com.alibaba.dubbo.config.MonitorConfig" + }, + { + "sourceType": "com.alibaba.dubbo.config.ApplicationConfig", + "name": "dubbo.application.name", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ApplicationConfig", + "name": "dubbo.application.organization", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ApplicationConfig", + "name": "dubbo.application.owner", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ApplicationConfig", + "name": "dubbo.application.parameters", + "type": "java.util.Map" + }, + { + "sourceType": "com.alibaba.dubbo.config.ApplicationConfig", + "name": "dubbo.application.qos-accept-foreign-ip", + "type": "java.lang.Boolean" + }, + { + "sourceType": "com.alibaba.dubbo.config.ApplicationConfig", + "name": "dubbo.application.qos-enable", + "type": "java.lang.Boolean" + }, + { + "sourceType": "com.alibaba.dubbo.config.ApplicationConfig", + "name": "dubbo.application.qos-port", + "type": "java.lang.Integer" + }, + { + "sourceType": "com.alibaba.dubbo.config.ApplicationConfig", + "name": "dubbo.application.registries", + "type": "java.util.List" + }, + { + "sourceType": "com.alibaba.dubbo.config.ApplicationConfig", + "name": "dubbo.application.registry", + "type": "com.alibaba.dubbo.config.RegistryConfig" + }, + { + "sourceType": "com.alibaba.dubbo.config.ApplicationConfig", + "name": "dubbo.application.version", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.boot.dubbo.autoconfigure.MultipleDubboConfigBindingProperties", + "name": "dubbo.applications", + "description": "Multiple {@link ApplicationConfig} property", + "type": "java.util.Map" + }, + { + "sourceType": "com.alibaba.boot.dubbo.autoconfigure.DubboConfigProperties", + "name": "dubbo.config.multiple", + "description": "Indicates multiple properties binding from externalized configuration or not.", + "type": "java.lang.Boolean" + }, + { + "sourceType": "com.alibaba.boot.dubbo.autoconfigure.DubboConfigProperties", + "name": "dubbo.config.override", + "description": "Indicates override {@link ConfigUtils#getProperties() Dubbo config properties} from externalized configuration\n or not.", + "type": "java.lang.Boolean" + }, + { + "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "name": "dubbo.consumer.actives", + "type": "java.lang.Integer" + }, + { + "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "name": "dubbo.consumer.application", + "type": "com.alibaba.dubbo.config.ApplicationConfig" + }, + { + "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "name": "dubbo.consumer.async", + "type": "java.lang.Boolean" + }, + { + "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "name": "dubbo.consumer.cache", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "name": "dubbo.consumer.callbacks", + "type": "java.lang.Integer" + }, + { + "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "name": "dubbo.consumer.check", + "type": "java.lang.Boolean" + }, + { + "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "name": "dubbo.consumer.client", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "name": "dubbo.consumer.cluster", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "name": "dubbo.consumer.connections", + "type": "java.lang.Integer" + }, + { + "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "name": "dubbo.consumer.default", + "type": "java.lang.Boolean" + }, + { + "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "name": "dubbo.consumer.filter", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "name": "dubbo.consumer.generic", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "name": "dubbo.consumer.group", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "name": "dubbo.consumer.id", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "name": "dubbo.consumer.init", + "type": "java.lang.Boolean" + }, + { + "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "deprecated": true, + "name": "dubbo.consumer.injvm", + "type": "java.lang.Boolean", + "deprecation": {} + }, + { + "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "name": "dubbo.consumer.layer", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "name": "dubbo.consumer.lazy", + "type": "java.lang.Boolean" + }, + { + "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "name": "dubbo.consumer.listener", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "name": "dubbo.consumer.loadbalance", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "deprecated": true, + "name": "dubbo.consumer.local", + "type": "java.lang.String", + "deprecation": {} + }, + { + "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "name": "dubbo.consumer.merger", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "name": "dubbo.consumer.mock", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "name": "dubbo.consumer.module", + "type": "com.alibaba.dubbo.config.ModuleConfig" + }, + { + "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "name": "dubbo.consumer.monitor", + "type": "com.alibaba.dubbo.config.MonitorConfig" + }, + { + "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "name": "dubbo.consumer.onconnect", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "name": "dubbo.consumer.ondisconnect", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "name": "dubbo.consumer.owner", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "name": "dubbo.consumer.parameters", + "type": "java.util.Map" + }, + { + "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "name": "dubbo.consumer.proxy", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "name": "dubbo.consumer.reconnect", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "name": "dubbo.consumer.registries", + "type": "java.util.List" + }, + { + "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "name": "dubbo.consumer.registry", + "type": "com.alibaba.dubbo.config.RegistryConfig" + }, + { + "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "name": "dubbo.consumer.retries", + "type": "java.lang.Integer" + }, + { + "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "name": "dubbo.consumer.scope", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "name": "dubbo.consumer.sent", + "type": "java.lang.Boolean" + }, + { + "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "name": "dubbo.consumer.sticky", + "type": "java.lang.Boolean" + }, + { + "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "name": "dubbo.consumer.stub", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "name": "dubbo.consumer.timeout", + "type": "java.lang.Integer" + }, + { + "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "name": "dubbo.consumer.validation", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ConsumerConfig", + "name": "dubbo.consumer.version", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.boot.dubbo.autoconfigure.MultipleDubboConfigBindingProperties", + "name": "dubbo.consumers", + "description": "Multiple {@link ConsumerConfig} property", + "type": "java.util.Map" + }, + { + "sourceType": "com.alibaba.dubbo.config.ModuleConfig", + "name": "dubbo.module.default", + "type": "java.lang.Boolean" + }, + { + "sourceType": "com.alibaba.dubbo.config.ModuleConfig", + "name": "dubbo.module.id", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ModuleConfig", + "name": "dubbo.module.monitor", + "type": "com.alibaba.dubbo.config.MonitorConfig" + }, + { + "sourceType": "com.alibaba.dubbo.config.ModuleConfig", + "name": "dubbo.module.name", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ModuleConfig", + "name": "dubbo.module.organization", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ModuleConfig", + "name": "dubbo.module.owner", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ModuleConfig", + "name": "dubbo.module.registries", + "type": "java.util.List" + }, + { + "sourceType": "com.alibaba.dubbo.config.ModuleConfig", + "name": "dubbo.module.registry", + "type": "com.alibaba.dubbo.config.RegistryConfig" + }, + { + "sourceType": "com.alibaba.dubbo.config.ModuleConfig", + "name": "dubbo.module.version", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.boot.dubbo.autoconfigure.MultipleDubboConfigBindingProperties", + "name": "dubbo.modules", + "description": "Multiple {@link ModuleConfig} property", + "type": "java.util.Map" + }, + { + "sourceType": "com.alibaba.dubbo.config.MonitorConfig", + "name": "dubbo.monitor.address", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.MonitorConfig", + "name": "dubbo.monitor.default", + "type": "java.lang.Boolean" + }, + { + "sourceType": "com.alibaba.dubbo.config.MonitorConfig", + "name": "dubbo.monitor.group", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.MonitorConfig", + "name": "dubbo.monitor.id", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.MonitorConfig", + "name": "dubbo.monitor.parameters", + "type": "java.util.Map" + }, + { + "sourceType": "com.alibaba.dubbo.config.MonitorConfig", + "name": "dubbo.monitor.password", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.MonitorConfig", + "name": "dubbo.monitor.protocol", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.MonitorConfig", + "name": "dubbo.monitor.username", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.MonitorConfig", + "name": "dubbo.monitor.version", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.boot.dubbo.autoconfigure.MultipleDubboConfigBindingProperties", + "name": "dubbo.monitors", + "description": "Multiple {@link MonitorConfig} property", + "type": "java.util.Map" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "name": "dubbo.protocol.accepts", + "type": "java.lang.Integer" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "name": "dubbo.protocol.accesslog", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "name": "dubbo.protocol.buffer", + "type": "java.lang.Integer" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "name": "dubbo.protocol.charset", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "name": "dubbo.protocol.client", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "name": "dubbo.protocol.codec", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "name": "dubbo.protocol.contextpath", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "name": "dubbo.protocol.default", + "type": "java.lang.Boolean" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "name": "dubbo.protocol.dispatcher", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "deprecated": true, + "name": "dubbo.protocol.dispather", + "type": "java.lang.String", + "deprecation": {} + }, + { + "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "name": "dubbo.protocol.exchanger", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "name": "dubbo.protocol.heartbeat", + "type": "java.lang.Integer" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "name": "dubbo.protocol.host", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "name": "dubbo.protocol.id", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "name": "dubbo.protocol.iothreads", + "type": "java.lang.Integer" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "name": "dubbo.protocol.name", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "name": "dubbo.protocol.networker", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "name": "dubbo.protocol.parameters", + "type": "java.util.Map" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "deprecated": true, + "name": "dubbo.protocol.path", + "type": "java.lang.String", + "deprecation": {} + }, + { + "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "name": "dubbo.protocol.payload", + "type": "java.lang.Integer" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "name": "dubbo.protocol.port", + "type": "java.lang.Integer" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "name": "dubbo.protocol.prompt", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "name": "dubbo.protocol.queues", + "type": "java.lang.Integer" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "name": "dubbo.protocol.register", + "type": "java.lang.Boolean" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "name": "dubbo.protocol.serialization", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "name": "dubbo.protocol.server", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "name": "dubbo.protocol.status", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "name": "dubbo.protocol.telnet", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "name": "dubbo.protocol.threadpool", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "name": "dubbo.protocol.threads", + "type": "java.lang.Integer" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProtocolConfig", + "name": "dubbo.protocol.transporter", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.boot.dubbo.autoconfigure.MultipleDubboConfigBindingProperties", + "name": "dubbo.protocols", + "description": "Multiple {@link ProtocolConfig} property", + "type": "java.util.Map" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.accepts", + "type": "java.lang.Integer" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.accesslog", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.actives", + "type": "java.lang.Integer" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.application", + "type": "com.alibaba.dubbo.config.ApplicationConfig" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.async", + "type": "java.lang.Boolean" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.buffer", + "type": "java.lang.Integer" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.cache", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.callbacks", + "type": "java.lang.Integer" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.charset", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.client", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.cluster", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.codec", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.connections", + "type": "java.lang.Integer" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.contextpath", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "deprecated": true, + "name": "dubbo.provider.default", + "type": "java.lang.Boolean", + "deprecation": {} + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.delay", + "type": "java.lang.Integer" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.deprecated", + "type": "java.lang.Boolean" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.dispatcher", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "deprecated": true, + "name": "dubbo.provider.dispather", + "type": "java.lang.String", + "deprecation": {} + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.document", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.dynamic", + "type": "java.lang.Boolean" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.exchanger", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.executes", + "type": "java.lang.Integer" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.export", + "type": "java.lang.Boolean" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.filter", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.group", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.host", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.id", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.iothreads", + "type": "java.lang.Integer" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.layer", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.listener", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.loadbalance", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "deprecated": true, + "name": "dubbo.provider.local", + "type": "java.lang.String", + "deprecation": {} + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.merger", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.mock", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.module", + "type": "com.alibaba.dubbo.config.ModuleConfig" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.monitor", + "type": "com.alibaba.dubbo.config.MonitorConfig" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.networker", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.onconnect", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.ondisconnect", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.owner", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.parameters", + "type": "java.util.Map" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "deprecated": true, + "name": "dubbo.provider.path", + "type": "java.lang.String", + "deprecation": {} + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.payload", + "type": "java.lang.Integer" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "deprecated": true, + "name": "dubbo.provider.port", + "type": "java.lang.Integer", + "deprecation": {} + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.prompt", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.protocol", + "type": "com.alibaba.dubbo.config.ProtocolConfig" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.protocols", + "type": "java.util.List" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.proxy", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.queues", + "type": "java.lang.Integer" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.register", + "type": "java.lang.Boolean" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.registries", + "type": "java.util.List" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.registry", + "type": "com.alibaba.dubbo.config.RegistryConfig" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.retries", + "type": "java.lang.Integer" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.scope", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.sent", + "type": "java.lang.Boolean" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.serialization", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.server", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.status", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.stub", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.telnet", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.threadpool", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.threads", + "type": "java.lang.Integer" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.timeout", + "type": "java.lang.Integer" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.token", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.transporter", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.validation", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.version", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.wait", + "type": "java.lang.Integer" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.warmup", + "type": "java.lang.Integer" + }, + { + "sourceType": "com.alibaba.dubbo.config.ProviderConfig", + "name": "dubbo.provider.weight", + "type": "java.lang.Integer" + }, + { + "sourceType": "com.alibaba.boot.dubbo.autoconfigure.MultipleDubboConfigBindingProperties", + "name": "dubbo.providers", + "description": "Multiple {@link ProviderConfig} property", + "type": "java.util.Map" + }, + { + "sourceType": "com.alibaba.boot.dubbo.autoconfigure.MultipleDubboConfigBindingProperties", + "name": "dubbo.registries", + "description": "Multiple {@link RegistryConfig} property", + "type": "java.util.Map" + }, + { + "sourceType": "com.alibaba.dubbo.config.RegistryConfig", + "name": "dubbo.registry.address", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.RegistryConfig", + "name": "dubbo.registry.check", + "type": "java.lang.Boolean" + }, + { + "sourceType": "com.alibaba.dubbo.config.RegistryConfig", + "name": "dubbo.registry.client", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.RegistryConfig", + "name": "dubbo.registry.cluster", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.RegistryConfig", + "name": "dubbo.registry.default", + "type": "java.lang.Boolean" + }, + { + "sourceType": "com.alibaba.dubbo.config.RegistryConfig", + "name": "dubbo.registry.dynamic", + "type": "java.lang.Boolean" + }, + { + "sourceType": "com.alibaba.dubbo.config.RegistryConfig", + "name": "dubbo.registry.file", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.RegistryConfig", + "name": "dubbo.registry.group", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.RegistryConfig", + "name": "dubbo.registry.id", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.RegistryConfig", + "name": "dubbo.registry.parameters", + "type": "java.util.Map" + }, + { + "sourceType": "com.alibaba.dubbo.config.RegistryConfig", + "name": "dubbo.registry.password", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.RegistryConfig", + "name": "dubbo.registry.port", + "type": "java.lang.Integer" + }, + { + "sourceType": "com.alibaba.dubbo.config.RegistryConfig", + "name": "dubbo.registry.protocol", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.RegistryConfig", + "name": "dubbo.registry.register", + "type": "java.lang.Boolean" + }, + { + "sourceType": "com.alibaba.dubbo.config.RegistryConfig", + "name": "dubbo.registry.server", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.RegistryConfig", + "name": "dubbo.registry.session", + "type": "java.lang.Integer" + }, + { + "sourceType": "com.alibaba.dubbo.config.RegistryConfig", + "name": "dubbo.registry.subscribe", + "type": "java.lang.Boolean" + }, + { + "sourceType": "com.alibaba.dubbo.config.RegistryConfig", + "name": "dubbo.registry.timeout", + "type": "java.lang.Integer" + }, + { + "sourceType": "com.alibaba.dubbo.config.RegistryConfig", + "deprecated": true, + "name": "dubbo.registry.transport", + "type": "java.lang.String", + "deprecation": {} + }, + { + "sourceType": "com.alibaba.dubbo.config.RegistryConfig", + "name": "dubbo.registry.transporter", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.RegistryConfig", + "name": "dubbo.registry.username", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.RegistryConfig", + "name": "dubbo.registry.version", + "type": "java.lang.String" + }, + { + "sourceType": "com.alibaba.dubbo.config.RegistryConfig", + "deprecated": true, + "name": "dubbo.registry.wait", + "type": "java.lang.Integer", + "deprecation": {} + }, + { + "sourceType": "com.alibaba.boot.dubbo.autoconfigure.DubboScanProperties", + "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" + } + ] +} \ No newline at end of file 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/autoconfigure/DubboAutoConfigurationOnMultipleConfigTest.java b/dubbo-spring-boot-autoconfigure/src/test/java/com/alibaba/boot/dubbo/autoconfigure/DubboAutoConfigurationOnMultipleConfigTest.java index 28521663f..938f29988 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 @@ -16,7 +16,14 @@ */ package com.alibaba.boot.dubbo.autoconfigure; -import com.alibaba.dubbo.config.*; +import com.alibaba.dubbo.config.ApplicationConfig; +import com.alibaba.dubbo.config.ConsumerConfig; +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.RegistryConfig; + import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; 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 f0e10b9f3..4c557f54e 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_GOOGLE_GROUP_URL; +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); @@ -48,13 +61,13 @@ public void testConstants() { Assert.assertEquals("dubbo.config.override", OVERRIDE_CONFIG_PROPERTY_NAME); - Assert.assertEquals("https://github.com/dubbo/dubbo-spring-boot-project", DUBBO_SPRING_BOOT_GITHUB_URL); - Assert.assertEquals("https://github.com/dubbo/dubbo-spring-boot-project.git", DUBBO_SPRING_BOOT_GIT_URL); - Assert.assertEquals("https://github.com/dubbo/dubbo-spring-boot-project/issues", DUBBO_SPRING_BOOT_ISSUES_URL); + Assert.assertEquals("https://github.com/apache/incubator-dubbo-spring-boot-project", DUBBO_SPRING_BOOT_GITHUB_URL); + Assert.assertEquals("https://github.com/apache/incubator-dubbo-spring-boot-project.git", DUBBO_SPRING_BOOT_GIT_URL); + Assert.assertEquals("https://github.com/apache/incubator-dubbo-spring-boot-project/issues", DUBBO_SPRING_BOOT_ISSUES_URL); - Assert.assertEquals("https://github.com/alibaba/dubbo", DUBBO_GITHUB_URL); + Assert.assertEquals("https://github.com/apache/incubator-dubbo", DUBBO_GITHUB_URL); - Assert.assertEquals("http://groups.google.com/group/dubbo", DUBBO_GOOGLE_GROUP_URL); + Assert.assertEquals("dev@dubbo.incubator.apache.org", DUBBO_GOOGLE_GROUP_URL); Assert.assertFalse(DEFAULT_MULTIPLE_CONFIG_PROPERTY_VALUE); diff --git a/dubbo-spring-boot-parent/pom.xml b/dubbo-spring-boot-parent/pom.xml index cf7101054..0e816c250 100644 --- a/dubbo-spring-boot-parent/pom.xml +++ b/dubbo-spring-boot-parent/pom.xml @@ -13,14 +13,14 @@ 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. - --> +--> com.alibaba.boot dubbo-spring-boot-project - 0.1.1 + 0.1.2-SNAPSHOT ../pom.xml @@ -37,11 +37,13 @@ 1.7 UTF-8 UTF-8 - 1.5.17.RELEASE + 1.5.18.RELEASE 2.6.5 0.2 3.4.9 2.12.0 + 1.0.2 + -server -Xms256m -Xmx512m -XX:PermSize=64m -XX:MaxPermSize=128m -Dfile.encoding=UTF-8 -Djava.net.preferIPv4Stack=true @@ -92,6 +94,13 @@ + + + com.alibaba.spring + spring-context-support + ${alibaba-spring-context-support.version} + + org.apache.zookeeper @@ -296,7 +305,7 @@ - [1.7,) + [1.8,) project.name @@ -416,6 +425,8 @@ **/*.fc **/*.javascript **/*.properties + **/*.yml + **/*.yaml **/*.thrift **/*.sh **/*.bat @@ -429,7 +440,6 @@ **/.project **/target/** **/*.log - pom.xml CODE_OF_CONDUCT.md .codecov.yml .travis.yml diff --git a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-api/pom.xml b/dubbo-spring-boot-samples/dubbo-spring-boot-sample-api/pom.xml index 971c9c1f3..baf5da24d 100644 --- a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-api/pom.xml +++ b/dubbo-spring-boot-samples/dubbo-spring-boot-sample-api/pom.xml @@ -13,14 +13,14 @@ 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. - --> +--> com.alibaba.boot dubbo-spring-boot-samples - 0.1.1 + 0.1.2-SNAPSHOT ../pom.xml 4.0.0 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 3af58644a..3637b7234 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 @@ -13,14 +13,14 @@ 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. - --> +--> com.alibaba.boot dubbo-spring-boot-samples - 0.1.1 + 0.1.2-SNAPSHOT ../pom.xml 4.0.0 @@ -47,6 +47,12 @@ ${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..e1db35288 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; @@ -32,7 +34,6 @@ public class DemoConsumerController { @Reference(version = "${demo.service.version}", - application = "${dubbo.application.id}", 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 dbca83749..000000000 --- a/dubbo-spring-boot-samples/dubbo-spring-boot-sample-consumer/src/main/resources/application.properties +++ /dev/null @@ -1,28 +0,0 @@ -# Spring boot application -spring.application.name = dubbo-consumer-demo -server.port = 8080 -management.port = 8081 -management.security.enabled = false - -# 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 \ 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..b61aec0e4 --- /dev/null +++ b/dubbo-spring-boot-samples/dubbo-spring-boot-sample-consumer/src/main/resources/application.yml @@ -0,0 +1,31 @@ +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/pom.xml b/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/pom.xml index 647cf2d6f..97365d7ef 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 @@ -13,14 +13,14 @@ 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. - --> +--> com.alibaba.boot dubbo-spring-boot-samples - 0.1.1 + 0.1.2-SNAPSHOT ../pom.xml 4.0.0 @@ -47,6 +47,12 @@ ${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/bootstrap/DubboProviderDemo.java b/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/src/main/java/com/alibaba/boot/dubbo/demo/provider/bootstrap/DubboProviderDemo.java index db3fcf115..70a99d7cc 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-spring-boot-sample-provider/src/main/java/com/alibaba/boot/dubbo/demo/provider/bootstrap/DubboProviderDemo.java @@ -17,6 +17,7 @@ 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.builder.SpringApplicationBuilder; @@ -31,11 +32,9 @@ public class DubboProviderDemo { public static void main(String[] args) { - new SpringApplicationBuilder(DubboProviderDemo.class) + .profiles("prod") .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/dubbo-spring-boot-sample-provider/src/main/java/com/alibaba/boot/dubbo/demo/provider/service/DefaultDemoService.java index 48bfc22bf..01ff1c6a5 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 @@ -28,7 +28,6 @@ */ @Service( version = "${demo.service.version}", - application = "${dubbo.application.id}", protocol = "${dubbo.protocol.id}", registry = "${dubbo.registry.id}" ) 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 new file mode 100644 index 000000000..421a14005 --- /dev/null +++ b/dubbo-spring-boot-samples/dubbo-spring-boot-sample-provider/src/main/resources/application-prod.properties @@ -0,0 +1,9 @@ +# 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 index 5828a7fe3..d0d1f2c91 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 @@ -1,7 +1,6 @@ # Spring boot application spring.application.name = dubbo-provider-demo server.port = 9090 -management.port = 9091 management.security.enabled = false # Service Version @@ -10,11 +9,8 @@ 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.id = dubbo-provider-demo -dubbo.application.name = dubbo-provider-demo dubbo.application.qos.port=22222 dubbo.application.qos.enable=true @@ -26,13 +22,4 @@ dubbo.protocol.status = server ## RegistryConfig Bean dubbo.registry.id = my-registry -dubbo.registry.address = N/A - -# 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 +dubbo.registry.address = N/A \ No newline at end of file diff --git a/dubbo-spring-boot-samples/pom.xml b/dubbo-spring-boot-samples/pom.xml index 16da5b0d4..28aab4495 100644 --- a/dubbo-spring-boot-samples/pom.xml +++ b/dubbo-spring-boot-samples/pom.xml @@ -13,14 +13,14 @@ 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. - --> +--> com.alibaba.boot dubbo-spring-boot-parent - 0.1.1 + 0.1.2-SNAPSHOT ../dubbo-spring-boot-parent/pom.xml 4.0.0 diff --git a/dubbo-spring-boot-starter/pom.xml b/dubbo-spring-boot-starter/pom.xml index 27ae65b26..43273b6e6 100644 --- a/dubbo-spring-boot-starter/pom.xml +++ b/dubbo-spring-boot-starter/pom.xml @@ -13,14 +13,14 @@ 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. - --> +--> com.alibaba.boot dubbo-spring-boot-parent - 0.1.1 + 0.1.2-SNAPSHOT ../dubbo-spring-boot-parent 4.0.0 diff --git a/pom.xml b/pom.xml index 93a3d84e6..c1c4df631 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ 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. - --> +--> 4.0.0 @@ -26,8 +26,7 @@ com.alibaba.boot dubbo-spring-boot-project - 0.1.1 - + 0.1.2-SNAPSHOT pom Dubbo Spring Boot Project