Polish apache/incubator-dubbo-spring-boot-project#467 : Set "spring.main.allow-bean-definition-overriding" property to be true as default
diff --git a/dubbo-spring-boot-compatible/autoconfigure/src/main/java/org/apache/dubbo/spring/boot/env/DubboDefaultPropertiesEnvironmentPostProcessor.java b/dubbo-spring-boot-compatible/autoconfigure/src/main/java/org/apache/dubbo/spring/boot/env/DubboDefaultPropertiesEnvironmentPostProcessor.java
index 0efbc6b..09aa40a 100644
--- a/dubbo-spring-boot-compatible/autoconfigure/src/main/java/org/apache/dubbo/spring/boot/env/DubboDefaultPropertiesEnvironmentPostProcessor.java
+++ b/dubbo-spring-boot-compatible/autoconfigure/src/main/java/org/apache/dubbo/spring/boot/env/DubboDefaultPropertiesEnvironmentPostProcessor.java
@@ -19,6 +19,7 @@
import org.apache.dubbo.config.ApplicationConfig;
import org.apache.dubbo.config.spring.context.annotation.EnableDubboConfig;
import org.apache.dubbo.config.spring.context.annotation.EnableDubboConfigBinding;
+
import org.springframework.boot.SpringApplication;
import org.springframework.boot.context.ContextIdApplicationContextInitializer;
import org.springframework.boot.env.EnvironmentPostProcessor;
@@ -73,6 +74,12 @@
*/
private static final String DUBBO_APPLICATION_QOS_ENABLE_PROPERTY = "dubbo.application.qos-enable";
+ /**
+ * The property name of "spring.main.allow-bean-definition-overriding".
+ * Please refer to: https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.1-Release-Notes#bean-overriding
+ */
+ public static final String ALLOW_BEAN_DEFINITION_OVERRIDING_PROPERTY = "spring.main.allow-bean-definition-overriding";
+
@Override
public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
MutablePropertySources propertySources = environment.getPropertySources();
@@ -92,6 +99,7 @@
setDubboApplicationNameProperty(environment, defaultProperties);
setDubboConfigMultipleProperty(defaultProperties);
setDubboApplicationQosEnableProperty(defaultProperties);
+ setAllowBeanDefinitionOverriding(defaultProperties);
return defaultProperties;
}
@@ -112,6 +120,18 @@
}
/**
+ * Set {@link #ALLOW_BEAN_DEFINITION_OVERRIDING_PROPERTY "spring.main.allow-bean-definition-overriding"} to be
+ * <code>true</code> as default.
+ *
+ * @param defaultProperties the default {@link Properties properties}
+ * @see #ALLOW_BEAN_DEFINITION_OVERRIDING_PROPERTY
+ * @since 2.7.1
+ */
+ private void setAllowBeanDefinitionOverriding(Map<String, Object> defaultProperties) {
+ defaultProperties.put(ALLOW_BEAN_DEFINITION_OVERRIDING_PROPERTY, Boolean.TRUE.toString());
+ }
+
+ /**
* Copy from BusEnvironmentPostProcessor#addOrReplace(MutablePropertySources, Map)
*
* @param propertySources {@link MutablePropertySources}