Commit ffe2e9b6 authored by Andy Wilkinson's avatar Andy Wilkinson

Clarify javadoc of SpringApplication.configureProfiles

Closes gh-2671
parent 1a11ed20
......@@ -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<String, Object> defaultProperties;
private Set<String> profiles = new HashSet<String>();
private Set<String> additionalProfiles = new HashSet<String>();
/**
* 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<String> profiles = new LinkedHashSet<String>(this.profiles);
Set<String> profiles = new LinkedHashSet<String>(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<String>(Arrays.asList(profiles));
this.additionalProfiles = new LinkedHashSet<String>(Arrays.asList(profiles));
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment