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