本文整理匯總了Java中org.springframework.core.env.StandardEnvironment.setActiveProfiles方法的典型用法代碼示例。如果您正苦於以下問題:Java StandardEnvironment.setActiveProfiles方法的具體用法?Java StandardEnvironment.setActiveProfiles怎麽用?Java StandardEnvironment.setActiveProfiles使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.core.env.StandardEnvironment
的用法示例。
在下文中一共展示了StandardEnvironment.setActiveProfiles方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: copyEnvironment
import org.springframework.core.env.StandardEnvironment; //導入方法依賴的package包/類
private StandardEnvironment copyEnvironment(ConfigurableEnvironment input) {
StandardEnvironment environment = new StandardEnvironment();
MutablePropertySources capturedPropertySources = environment.getPropertySources();
// Only copy the default property source(s) and the profiles over from the main
// environment (everything else should be pristine, just like it was on startup).
for (String name : DEFAULT_PROPERTY_SOURCES) {
if (input.getPropertySources().contains(name)) {
if (capturedPropertySources.contains(name)) {
capturedPropertySources.replace(name,
input.getPropertySources().get(name));
}
else {
capturedPropertySources.addLast(input.getPropertySources().get(name));
}
}
}
environment.setActiveProfiles(input.getActiveProfiles());
environment.setDefaultProfiles(input.getDefaultProfiles());
Map<String, Object> map = new HashMap<String, Object>();
map.put("spring.jmx.enabled", false);
map.put("spring.main.sources", "");
capturedPropertySources
.addFirst(new MapPropertySource(REFRESH_ARGS_PROPERTY_SOURCE, map));
return environment;
}
示例2: createEnvironment
import org.springframework.core.env.StandardEnvironment; //導入方法依賴的package包/類
@Override
protected ConfigurableEnvironment createEnvironment() {
loadProperties();
StandardEnvironment env = new StandardEnvironment();
validateMode(nsiRequesterMode, ImmutableList.of("nsi-requester", "nsi-requester-offline"));
validateMode(organizationClientMode, ImmutableList.of("kis", "kis-offline"));
validateMode(vootMode, ImmutableList.of("voot", "voot-offline"));
env.setActiveProfiles(nsiRequesterMode, organizationClientMode, vootMode);
if (sslReplies) {
env.addActiveProfile("stunnel");
}
LOGGER.info("Starting with active profiles: {}", Stream.of(env.getActiveProfiles()).collect(joining(", ")));
return env;
}
示例3: beanFactoryFor
import org.springframework.core.env.StandardEnvironment; //導入方法依賴的package包/類
private BeanDefinitionRegistry beanFactoryFor(String xmlName, String... activeProfiles) {
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(beanFactory);
StandardEnvironment env = new StandardEnvironment();
env.setActiveProfiles(activeProfiles);
reader.setEnvironment(env);
reader.loadBeanDefinitions(new ClassPathResource(xmlName, getClass()));
return beanFactory;
}
示例4: convertToStandardEnvironment
import org.springframework.core.env.StandardEnvironment; //導入方法依賴的package包/類
private ConfigurableEnvironment convertToStandardEnvironment(
ConfigurableEnvironment environment) {
StandardEnvironment result = new StandardEnvironment();
removeAllPropertySources(result.getPropertySources());
result.setActiveProfiles(environment.getActiveProfiles());
for (PropertySource<?> propertySource : environment.getPropertySources()) {
if (!SERVLET_ENVIRONMENT_SOURCE_NAMES.contains(propertySource.getName())) {
result.getPropertySources().addLast(propertySource);
}
}
return result;
}
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:13,代碼來源:SpringApplication.java