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


Java ConfigurableEnvironment.getActiveProfiles方法代碼示例

本文整理匯總了Java中org.springframework.core.env.ConfigurableEnvironment.getActiveProfiles方法的典型用法代碼示例。如果您正苦於以下問題:Java ConfigurableEnvironment.getActiveProfiles方法的具體用法?Java ConfigurableEnvironment.getActiveProfiles怎麽用?Java ConfigurableEnvironment.getActiveProfiles使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.core.env.ConfigurableEnvironment的用法示例。


在下文中一共展示了ConfigurableEnvironment.getActiveProfiles方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onApplicationEvent

import org.springframework.core.env.ConfigurableEnvironment; //導入方法依賴的package包/類
@Override
public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) {
	// 設置動態加載文件要使用的active.profile係統變量
	ConfigurableEnvironment env = event.getEnvironment();
	if(env != null){
		System.out.println("start eds Application , active profiles : "
				+ Arrays.toString(env.getActiveProfiles()));
		String[] activeProfiles = env.getActiveProfiles();
		if(activeProfiles != null && activeProfiles.length > 0){
			String active = activeProfiles[0];
			System.setProperty("spring.profiles.active",active);
			System.out.println("eds system property [spring.profiles.active] variable : "+active);
		}
	}
}
 
開發者ID:eXcellme,項目名稱:eds,代碼行數:16,代碼來源:Application.java

示例2: prependProfile

import org.springframework.core.env.ConfigurableEnvironment; //導入方法依賴的package包/類
private void prependProfile(ConfigurableEnvironment environment,
		Profile profile) {
	Set<String> profiles = new LinkedHashSet<String>();
	environment.getActiveProfiles(); // ensure they are initialized
	// But this one should go first (last wins in a property key clash)
	profiles.add(profile.getName());
	profiles.addAll(Arrays.asList(environment.getActiveProfiles()));
	environment.setActiveProfiles(profiles.toArray(new String[profiles.size()]));
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:10,代碼來源:ConfigFileApplicationListener.java

示例3: loadProfileProperties

import org.springframework.core.env.ConfigurableEnvironment; //導入方法依賴的package包/類
private void loadProfileProperties(ConfigurableEnvironment environment) throws IOException {
  String[] activeProfiles = environment.getActiveProfiles();
  if(activeProfiles != null && activeProfiles.length > 0)
    loadProfileProperties(environment, activeProfiles);
  else
    loadProfileProperties(environment, environment.getDefaultProfiles());
}
 
開發者ID:coders-kitchen,項目名稱:spring-boot-multi-module-property-files,代碼行數:8,代碼來源:PropertyFilePatternRegisteringListener.java

示例4: prependProfile

import org.springframework.core.env.ConfigurableEnvironment; //導入方法依賴的package包/類
private void prependProfile(ConfigurableEnvironment environment, String profile) {
	Set<String> profiles = new LinkedHashSet<String>();
	environment.getActiveProfiles(); // ensure they are initialized
	// But this one should go first (last wins in a property key clash)
	profiles.add(profile);
	profiles.addAll(Arrays.asList(environment.getActiveProfiles()));
	environment.setActiveProfiles(profiles.toArray(new String[profiles.size()]));
}
 
開發者ID:philwebb,項目名稱:spring-boot-concourse,代碼行數:9,代碼來源:ConfigFileApplicationListener.java

示例5: configureProfiles

import org.springframework.core.env.ConfigurableEnvironment; //導入方法依賴的package包/類
/**
 * Configure which profiles are active (or active by default) for this application
 * 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 org.springframework.boot.context.config.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.additionalProfiles);
	profiles.addAll(Arrays.asList(environment.getActiveProfiles()));
	environment.setActiveProfiles(profiles.toArray(new String[profiles.size()]));
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:17,代碼來源:SpringApplication.java


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