diff --git a/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java b/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java index 657c4180f98..e3f2ab0016b 100644 --- a/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java +++ b/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java @@ -37,6 +37,7 @@ import org.springframework.beans.factory.groovy.GroovyBeanDefinitionReader; import org.springframework.beans.factory.support.BeanDefinitionRegistry; import org.springframework.beans.factory.support.BeanNameGenerator; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; +import org.springframework.boot.context.config.ConfigFileApplicationListener; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextInitializer; import org.springframework.context.ApplicationListener; @@ -191,7 +192,7 @@ public class SpringApplication { private Map defaultProperties; - private Set profiles = new HashSet(); + private Set additionalProfiles = new HashSet(); /** * Create a new {@link SpringApplication} instance. The application context will load @@ -450,17 +451,17 @@ public class SpringApplication { /** * Configure which profiles are active (or active by default) for this application - * environment. Consider overriding this method to programmatically enforce profile - * rules and semantics, such as ensuring mutual exclusivity of profiles (e.g. 'dev' OR - * 'prod', but never both). + * environment. Additional profiles may be activated during configuration file + * processing via the {@code spring.profiles.active} property. * @param environment this application's environment * @param args arguments passed to the {@code run} method * @see #configureEnvironment(ConfigurableEnvironment, String[]) + * @see ConfigFileApplicationListener */ protected void configureProfiles(ConfigurableEnvironment environment, String[] args) { environment.getActiveProfiles(); // ensure they are initialized // But these ones should go first (last wins in a property key clash) - Set profiles = new LinkedHashSet(this.profiles); + Set profiles = new LinkedHashSet(this.additionalProfiles); profiles.addAll(Arrays.asList(environment.getActiveProfiles())); environment.setActiveProfiles(profiles.toArray(new String[profiles.size()])); } @@ -822,7 +823,7 @@ public class SpringApplication { * @param profiles the additional profiles to set */ public void setAdditionalProfiles(String... profiles) { - this.profiles = new LinkedHashSet(Arrays.asList(profiles)); + this.additionalProfiles = new LinkedHashSet(Arrays.asList(profiles)); } /**