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


Java PropertySourcesPlaceholderConfigurer.setProperties方法代碼示例

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


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

示例1: propertyPlaceholderConfigurer

import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; //導入方法依賴的package包/類
@Bean
public static PropertySourcesPlaceholderConfigurer propertyPlaceholderConfigurer() {
    PropertySourcesPlaceholderConfigurer placeholderConfigurer = new PropertySourcesPlaceholderConfigurer();
    placeholderConfigurer.setFileEncoding("UTF-8");

    Properties properties = EnvLoader.getEnvs();
    if (properties.isEmpty()) {
        ParamsHome.getInstance().init(StringUtils.EMPTY);
        EnvLoader.init();
        IniLoader.init();

        properties = EnvLoader.getEnvs();
    }

    placeholderConfigurer.setProperties(properties);

    return placeholderConfigurer;
}
 
開發者ID:lodsve,項目名稱:lodsve-framework,代碼行數:19,代碼來源:LodsveCoreConfiguration.java

示例2: postProcessEmbeddedServletContainerFactory

import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; //導入方法依賴的package包/類
@Test
public void postProcessEmbeddedServletContainerFactory() throws Exception {
	RootBeanDefinition bd = new RootBeanDefinition(
			MockEmbeddedServletContainerFactory.class);
	MutablePropertyValues pv = new MutablePropertyValues();
	pv.add("port", "${port}");
	bd.setPropertyValues(pv);
	this.context.registerBeanDefinition("embeddedServletContainerFactory", bd);

	PropertySourcesPlaceholderConfigurer propertySupport = new PropertySourcesPlaceholderConfigurer();
	Properties properties = new Properties();
	properties.put("port", 8080);
	propertySupport.setProperties(properties);
	this.context.registerBeanDefinition("propertySupport",
			beanDefinition(propertySupport));

	this.context.refresh();
	assertThat(getEmbeddedServletContainerFactory().getContainer().getPort())
			.isEqualTo(8080);
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:21,代碼來源:EmbeddedWebApplicationContextTests.java

示例3: properties

import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; //導入方法依賴的package包/類
@Bean
public PropertySourcesPlaceholderConfigurer properties() {
    PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer = new PropertySourcesPlaceholderConfigurer();
    YamlPropertiesFactoryBean yamlPropertiesFactory = new YamlPropertiesFactoryBean();
    ConfigurationFileResourceResolver configurationFileResourceResolver = new ConfigurationFileResourceResolver();

    yamlPropertiesFactory.setResources(configurationFileResourceResolver.getResourceArray());
    propertySourcesPlaceholderConfigurer.setProperties(yamlPropertiesFactory.getObject());

    return propertySourcesPlaceholderConfigurer;
}
 
開發者ID:RFTDevGroup,項目名稱:RFTBackend,代碼行數:12,代碼來源:CustomYamlConfig.java

示例4: configurer

import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; //導入方法依賴的package包/類
/**
 * Make vars.properties available to spring integration configuration
 * System properties are only used if there is no setting in vars.properties.
 */
@Bean(name = "aemServiceConfigurationPropertiesConfigurer")
public static PropertySourcesPlaceholderConfigurer configurer() {
    PropertySourcesPlaceholderConfigurer ppc = new PropertySourcesPlaceholderConfigurer();
    ppc.setLocation(new ClassPathResource("META-INF/spring/jwala-defaults.properties"));
    ppc.setLocalOverride(true);
    ppc.setProperties(ApplicationProperties.getProperties());
    return ppc;
}
 
開發者ID:cerner,項目名稱:jwala,代碼行數:13,代碼來源:AemServiceConfiguration.java

示例5: properties

import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; //導入方法依賴的package包/類
@Bean
public static PropertySourcesPlaceholderConfigurer properties(@Qualifier("graviteeProperties") Properties graviteeProperties) {
    PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer = new PropertySourcesPlaceholderConfigurer();
    propertySourcesPlaceholderConfigurer.setProperties(graviteeProperties);
    propertySourcesPlaceholderConfigurer.setIgnoreUnresolvablePlaceholders(true);

    return propertySourcesPlaceholderConfigurer;
}
 
開發者ID:gravitee-io,項目名稱:graviteeio-access-management,代碼行數:9,代碼來源:EnvironmentConfiguration.java

示例6: morePlaceholders

import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; //導入方法依賴的package包/類
@Bean
public static PropertySourcesPlaceholderConfigurer morePlaceholders() {
	PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer();
	configurer.setProperties(StringUtils
			.splitArrayElementsIntoProperties(new String[] { "foo=spam" }, "="));
	configurer.setLocalOverride(true);
	configurer.setOrder(0);
	return configurer;
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:10,代碼來源:PropertyPlaceholderAutoConfigurationTests.java

示例7: properties

import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; //導入方法依賴的package包/類
@Bean
public static PropertySourcesPlaceholderConfigurer properties() {
    PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer = new PropertySourcesPlaceholderConfigurer();

    propertySourcesPlaceholderConfigurer.setIgnoreResourceNotFound(false);

    ArrayList<String> defaultSources = new ArrayList(Arrays.asList("raptor.yml", appName + ".yml"));

    if (additionalConfigNames != null && !additionalConfigNames.isEmpty()) {
        defaultSources.addAll(additionalConfigNames);
    }

    ArrayList<String> sources = new ArrayList(defaultSources);

    if (developmentMode) {
        defaultSources.forEach((source) -> {
            sources.add(source.replace(".yml", ".dev.yml"));
        });
    }

    try {
        String envPath = System.getenv("CONFIG_BASEPATH");
        if (envPath != null && envPath.isEmpty()) {
            log.debug("Using CONFIG_BASEPATH={}", envPath);
            basepath = envPath;
        }
    } catch (Exception e) {
        log.warn("Failed to read environment variable CONFIG_BASEPATH: %s", e.getMessage());
    }

    log.debug("Configuration path {}", basepath);

    List<Resource> resources = sources.stream()
            .filter(f -> new File(basepath + f).exists())
            .map(f -> new FileSystemResource(basepath + f))
            .collect(Collectors.toList());

    log.debug("Configuration sources: {}", resources.toString());

    if (resources.isEmpty()) {
        throw new RuntimeException("Cannot find a loadable property file in: " + basepath);
    }

    YamlPropertiesFactoryBean yaml = new YamlPropertiesFactoryBean();
    yaml.setResources(resources.toArray(new Resource[]{}));

    propertySourcesPlaceholderConfigurer.setProperties(yaml.getObject());
    return propertySourcesPlaceholderConfigurer;
}
 
開發者ID:raptorbox,項目名稱:raptor,代碼行數:50,代碼來源:BaseApplication.java


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