diff --git a/spring-cloud-context/src/main/java/org/springframework/cloud/bootstrap/BootstrapApplicationListener.java b/spring-cloud-context/src/main/java/org/springframework/cloud/bootstrap/BootstrapApplicationListener.java index 3357fb4b..3ef9bf8e 100644 --- a/spring-cloud-context/src/main/java/org/springframework/cloud/bootstrap/BootstrapApplicationListener.java +++ b/spring-cloud-context/src/main/java/org/springframework/cloud/bootstrap/BootstrapApplicationListener.java @@ -46,6 +46,7 @@ import org.springframework.core.env.MutablePropertySources; import org.springframework.core.env.PropertySource; import org.springframework.core.env.StandardEnvironment; import org.springframework.core.env.SystemEnvironmentPropertySource; +import org.springframework.core.env.PropertySource.StubPropertySource; import org.springframework.core.io.support.SpringFactoriesLoader; import org.springframework.util.ClassUtils; import org.springframework.util.ReflectionUtils; @@ -144,6 +145,9 @@ public class BootstrapApplicationListener bootstrapProperties.addFirst( new MapPropertySource(BOOTSTRAP_PROPERTY_SOURCE_NAME, bootstrapMap)); for (PropertySource source : environment.getPropertySources()) { + if (source instanceof StubPropertySource) { + continue; + } bootstrapProperties.addLast(source); } ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/context/refresh/ContextRefresherTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/context/refresh/ContextRefresherTests.java index a7e6975e..39f0891f 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/context/refresh/ContextRefresherTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/context/refresh/ContextRefresherTests.java @@ -41,7 +41,8 @@ public class ContextRefresherTests { .contains("applicationConfig: [classpath:/bootstrap-refresh.properties]"); assertThat(names).containsSequence( "applicationConfig: [classpath:/application.properties]", - "applicationConfig: [classpath:/bootstrap-refresh.properties]"); + "applicationConfig: [classpath:/bootstrap-refresh.properties]", + "applicationConfig: [classpath:/bootstrap.properties]"); } } @@ -77,7 +78,7 @@ public class ContextRefresherTests { protected static class PropertySourceConfiguration implements PropertySourceLocator { public static Map MAP = new HashMap<>( - Collections.singletonMap("bootstrap.context-refresh.foo", "refresh")); + Collections.singletonMap("bootstrap.foo", "refresh")); @Override public PropertySource locate(Environment environment) {