本文整理匯總了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);
}
}