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


Java ConfigurableEnvironment.addActiveProfile方法代碼示例

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


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

示例1: initialize

import org.springframework.core.env.ConfigurableEnvironment; //導入方法依賴的package包/類
@Override
public void initialize(ConfigurableApplicationContext applicationContext) {
    ConfigurableEnvironment configEnv = applicationContext.getEnvironment();

    Configuration profileConfig = Env.getFrameworkEnv("profiles.properties");
    Set<String> profiles = profileConfig.subset("profiles").getKeys();

    if (CollectionUtils.isEmpty(profiles)) {
        return;
    }

    for (String profile : profiles) {
        if (profileConfig.getBoolean("profiles." + profile, false)) {
            configEnv.addActiveProfile(profile);
        }
    }
}
 
開發者ID:lodsve,項目名稱:lodsve-framework,代碼行數:18,代碼來源:ProfileInitializer.java

示例2: addKubernetesProfile

import org.springframework.core.env.ConfigurableEnvironment; //導入方法依賴的package包/類
void addKubernetesProfile(ConfigurableEnvironment environment) {
    Pod current = utils.currentPod().get();
    if (current != null) {
        if (!hasKubernetesProfile(environment)) {
            environment.addActiveProfile(KUBERNETES_PROFILE);
        }
    }

    if (utils.isInsideKubernetes()) {
        if (hasKubernetesProfile(environment)) {
            LOGGER.debug("'kubernetes' already in list of active profiles");
        } else {
            LOGGER.debug("Adding 'kubernetes' to list of active profiles");
            environment.addActiveProfile(KUBERNETES_PROFILE);
        }
    } else {
        if (LOGGER.isDebugEnabled()) {
            LOGGER.warn("Not running inside kubernetes. Skipping 'kuberntes' profile activation.");
        }
    }
}
 
開發者ID:fabric8io,項目名稱:spring-cloud-kubernetes,代碼行數:22,代碼來源:KubernetesProfileApplicationListener.java

示例3: postProcessEnvironment

import org.springframework.core.env.ConfigurableEnvironment; //導入方法依賴的package包/類
@Override
public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
    Assert.notNull(propName);
    String val = environment.getProperty(propName);
    if (StringUtils.hasText(val)) {
        List<String> list = Arrays.asList(StringUtils.commaDelimitedListToStringArray(
                environment.resolvePlaceholders(val)));
        Collections.reverse(list);
        for (String item : list) {
            if (!environment.acceptsProfiles(item)) {
                environment.addActiveProfile(item);
                log.info("Added active profile : {}", item);
            } else {
                log.info("Active profile '{}' has already existed.", item);
            }
        }
    }
}
 
開發者ID:easycodebox,項目名稱:easycode,代碼行數:19,代碼來源:ActiveProfileEnvironmentPostProcessor.java

示例4: initialize

import org.springframework.core.env.ConfigurableEnvironment; //導入方法依賴的package包/類
@Override
public void initialize(ConfigurableApplicationContext applicationContext) {
    Cloud cloud = getCloud();

    ConfigurableEnvironment appEnvironment = applicationContext.getEnvironment();

    String[] persistenceProfiles = getCloudProfiles(cloud);
    if (persistenceProfiles == null) {
        persistenceProfiles = new String[] { IN_MEMORY_PROFILE };
    }

    for (String persistenceProfile : persistenceProfiles) {
        appEnvironment.addActiveProfile(persistenceProfile);
    }
}
 
開發者ID:gluonhq,項目名稱:gluon-samples,代碼行數:16,代碼來源:ContextInitializer.java


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