本文整理汇总了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);
}
}
}
示例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.");
}
}
}
示例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);
}
}
}
}
示例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);
}
}