Skip to content

Commit ffe2e9b

Browse files
committed
Clarify javadoc of SpringApplication.configureProfiles
Closes spring-projectsgh-2671
1 parent 1a11ed2 commit ffe2e9b

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

spring-boot/src/main/java/org/springframework/boot/SpringApplication.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
3838
import org.springframework.beans.factory.support.BeanNameGenerator;
3939
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
40+
import org.springframework.boot.context.config.ConfigFileApplicationListener;
4041
import org.springframework.context.ApplicationContext;
4142
import org.springframework.context.ApplicationContextInitializer;
4243
import org.springframework.context.ApplicationListener;
@@ -191,7 +192,7 @@ public class SpringApplication {
191192

192193
private Map<String, Object> defaultProperties;
193194

194-
private Set<String> profiles = new HashSet<String>();
195+
private Set<String> additionalProfiles = new HashSet<String>();
195196

196197
/**
197198
* Create a new {@link SpringApplication} instance. The application context will load
@@ -450,17 +451,17 @@ protected void configurePropertySources(ConfigurableEnvironment environment,
450451

451452
/**
452453
* 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.
456456
* @param environment this application's environment
457457
* @param args arguments passed to the {@code run} method
458458
* @see #configureEnvironment(ConfigurableEnvironment, String[])
459+
* @see ConfigFileApplicationListener
459460
*/
460461
protected void configureProfiles(ConfigurableEnvironment environment, String[] args) {
461462
environment.getActiveProfiles(); // ensure they are initialized
462463
// 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);
464465
profiles.addAll(Arrays.asList(environment.getActiveProfiles()));
465466
environment.setActiveProfiles(profiles.toArray(new String[profiles.size()]));
466467
}
@@ -822,7 +823,7 @@ public void setDefaultProperties(Properties defaultProperties) {
822823
* @param profiles the additional profiles to set
823824
*/
824825
public void setAdditionalProfiles(String... profiles) {
825-
this.profiles = new LinkedHashSet<String>(Arrays.asList(profiles));
826+
this.additionalProfiles = new LinkedHashSet<String>(Arrays.asList(profiles));
826827
}
827828

828829
/**

0 commit comments

Comments
 (0)