|
37 | 37 | import org.springframework.beans.factory.support.BeanDefinitionRegistry; |
38 | 38 | import org.springframework.beans.factory.support.BeanNameGenerator; |
39 | 39 | import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; |
| 40 | +import org.springframework.boot.context.config.ConfigFileApplicationListener; |
40 | 41 | import org.springframework.context.ApplicationContext; |
41 | 42 | import org.springframework.context.ApplicationContextInitializer; |
42 | 43 | import org.springframework.context.ApplicationListener; |
@@ -191,7 +192,7 @@ public class SpringApplication { |
191 | 192 |
|
192 | 193 | private Map<String, Object> defaultProperties; |
193 | 194 |
|
194 | | - private Set<String> profiles = new HashSet<String>(); |
| 195 | + private Set<String> additionalProfiles = new HashSet<String>(); |
195 | 196 |
|
196 | 197 | /** |
197 | 198 | * Create a new {@link SpringApplication} instance. The application context will load |
@@ -450,17 +451,17 @@ protected void configurePropertySources(ConfigurableEnvironment environment, |
450 | 451 |
|
451 | 452 | /** |
452 | 453 | * Configure which profiles are active (or active by default) for this application |
453 | | - * environment. Consider overriding this method to programmatically enforce profile |
454 | | - * rules and semantics, such as ensuring mutual exclusivity of profiles (e.g. 'dev' OR |
455 | | - * 'prod', but never both). |
| 454 | + * environment. Additional profiles may be activated during configuration file |
| 455 | + * processing via the {@code spring.profiles.active} property. |
456 | 456 | * @param environment this application's environment |
457 | 457 | * @param args arguments passed to the {@code run} method |
458 | 458 | * @see #configureEnvironment(ConfigurableEnvironment, String[]) |
| 459 | + * @see ConfigFileApplicationListener |
459 | 460 | */ |
460 | 461 | protected void configureProfiles(ConfigurableEnvironment environment, String[] args) { |
461 | 462 | environment.getActiveProfiles(); // ensure they are initialized |
462 | 463 | // But these ones should go first (last wins in a property key clash) |
463 | | - Set<String> profiles = new LinkedHashSet<String>(this.profiles); |
| 464 | + Set<String> profiles = new LinkedHashSet<String>(this.additionalProfiles); |
464 | 465 | profiles.addAll(Arrays.asList(environment.getActiveProfiles())); |
465 | 466 | environment.setActiveProfiles(profiles.toArray(new String[profiles.size()])); |
466 | 467 | } |
@@ -822,7 +823,7 @@ public void setDefaultProperties(Properties defaultProperties) { |
822 | 823 | * @param profiles the additional profiles to set |
823 | 824 | */ |
824 | 825 | public void setAdditionalProfiles(String... profiles) { |
825 | | - this.profiles = new LinkedHashSet<String>(Arrays.asList(profiles)); |
| 826 | + this.additionalProfiles = new LinkedHashSet<String>(Arrays.asList(profiles)); |
826 | 827 | } |
827 | 828 |
|
828 | 829 | /** |
|
0 commit comments