當前位置: 首頁>>代碼示例>>Java>>正文


Java StandardEnvironment.setActiveProfiles方法代碼示例

本文整理匯總了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;
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-commons,代碼行數:26,代碼來源:ContextRefresher.java

示例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;
}
 
開發者ID:BandwidthOnDemand,項目名稱:bandwidth-on-demand,代碼行數:21,代碼來源:AppConfigWebApplicationContext.java

示例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;
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:10,代碼來源:ProfileXmlBeanDefinitionTests.java

示例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


注:本文中的org.springframework.core.env.StandardEnvironment.setActiveProfiles方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。