当前位置: 首页>>代码示例>>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;未经允许,请勿转载。