Merge branch '1.5.x'
This commit is contained in:
@@ -393,8 +393,11 @@ public class ConfigFileApplicationListener implements EnvironmentPostProcessor,
|
||||
}
|
||||
// Any pre-existing active profiles set via property sources (e.g. System
|
||||
// properties) take precedence over those added in config files.
|
||||
Set<Profile> activeProfiles = bindSpringProfiles(
|
||||
this.environment.getPropertySources()).getActiveProfiles();
|
||||
SpringProfiles springProfiles = bindSpringProfiles(
|
||||
this.environment.getPropertySources());
|
||||
Set<Profile> activeProfiles = new LinkedHashSet<Profile>(
|
||||
springProfiles.getActiveProfiles());
|
||||
activeProfiles.addAll(springProfiles.getIncludeProfiles());
|
||||
maybeActivateProfiles(activeProfiles);
|
||||
return activeProfiles;
|
||||
}
|
||||
|
||||
@@ -837,6 +837,18 @@ public class ConfigFileApplicationListenerTests {
|
||||
assertThat(environment.acceptsProfiles("customdefault")).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void additionalProfilesCanBeIncludedFromAnyPropertySource() throws Exception {
|
||||
SpringApplication application = new SpringApplication(Config.class);
|
||||
application.setWebEnvironment(false);
|
||||
this.context = application.run("--spring.profiles.active=myprofile",
|
||||
"--spring.profiles.include=dev");
|
||||
String property = this.context.getEnvironment().getProperty("my.property");
|
||||
assertThat(property).isEqualTo("fromdevpropertiesfile");
|
||||
assertThat(this.context.getEnvironment().containsProperty("customdefault"))
|
||||
.isFalse();
|
||||
}
|
||||
|
||||
private Condition<ConfigurableEnvironment> matchingPropertySource(
|
||||
final String sourceName) {
|
||||
return new Condition<ConfigurableEnvironment>(
|
||||
|
||||
Reference in New Issue
Block a user