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


Java PropertySourcesPlaceholderConfigurer類代碼示例

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


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

示例1: propertiesForIntegration

import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; //導入依賴的package包/類
@Bean
@Profile("integration")
public static PropertySourcesPlaceholderConfigurer propertiesForIntegration()
        throws Exception {
    String file = "application-integration-local.properties";

    String envIntegration = System.getenv("CLOUDUNIT_JENKINS_CI");
    if ("true".equalsIgnoreCase(envIntegration)) {
        file = "application-integration.properties";
    }

    PropertySourcesPlaceholderConfigurer pspc =
            new PropertySourcesPlaceholderConfigurer();
    pspc.setLocations(getResources(file));
    pspc.setIgnoreUnresolvablePlaceholders(true);
    pspc.setLocalOverride(true);
    return pspc;
}
 
開發者ID:oncecloud,項目名稱:devops-cstack,代碼行數:19,代碼來源:CloudUnitApplicationContext.java

示例2: mergePropertySource

import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; //導入依賴的package包/類
protected void mergePropertySource() throws Exception {
	if (this.environment != null) {
		this.addLast(new PropertySource<Environment>(PropertySourcesPlaceholderConfigurer.ENVIRONMENT_PROPERTIES_PROPERTY_SOURCE_NAME, this.environment) {
			public String getProperty(String key) {
				return this.source.getProperty(key);
			}
		});
	} else {
		logger.warn("The injected environment was null!");
	}
	if (this.locations != null && this.locations.length > 0) {
		Properties localProperties = new Properties();
		loadProperties(localProperties);
		PropertySource<?> localPropertySource = new PropertiesPropertySource(PropertySourcesPlaceholderConfigurer.LOCAL_PROPERTIES_PROPERTY_SOURCE_NAME, localProperties);
		if (this.localOverride) {
			this.addFirst(localPropertySource);
		} else {
			this.addLast(localPropertySource);
		}
	}
}
 
開發者ID:penggle,項目名稱:xproject,代碼行數:22,代碼來源:GlobalPropertySources.java

示例3: registerBeanDefinitions

import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; //導入依賴的package包/類
@Override
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
  AnnotationAttributes attributes = AnnotationAttributes.fromMap(importingClassMetadata
      .getAnnotationAttributes(EnableApolloConfig.class.getName()));
  String[] namespaces = attributes.getStringArray("value");
  int order = attributes.getNumber("order");
  PropertySourcesProcessor.addNamespaces(Lists.newArrayList(namespaces), order);

  BeanRegistrationUtil.registerBeanDefinitionIfNotExists(registry, PropertySourcesPlaceholderConfigurer.class.getName(),
      PropertySourcesPlaceholderConfigurer.class);

  BeanRegistrationUtil.registerBeanDefinitionIfNotExists(registry, PropertySourcesProcessor.class.getName(),
      PropertySourcesProcessor.class);

  BeanRegistrationUtil.registerBeanDefinitionIfNotExists(registry, ApolloAnnotationProcessor.class.getName(),
      ApolloAnnotationProcessor.class);
}
 
開發者ID:dewey-its,項目名稱:apollo-custom,代碼行數:18,代碼來源:ApolloConfigRegistrar.java

示例4: 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

示例5: 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:philwebb,項目名稱:spring-boot-concourse,代碼行數:21,代碼來源:EmbeddedWebApplicationContextTests.java

示例6: postProcess

import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; //導入依賴的package包/類
public void postProcess(ConfigurableListableBeanFactory beanFactory) {
    // 注冊 Spring 屬性配置
    PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer();
    MutablePropertySources mutablePropertySources = new MutablePropertySources();
    mutablePropertySources.addLast(new PropertySource<String>(Configs.class.getName()) {
        @Override
        public String getProperty(String name) {
            return Configs.getString(name);
        }
    });
    configurer.setPropertySources(mutablePropertySources);
    configurer.postProcessBeanFactory(beanFactory);

    /*
     * 注冊 @ConfigValue 處理器. ConfigValueBeanPostProcessor 實現了 ApplicationListener 接口, 不能使用
     * beanFactory.addBeanPostProcessor() 來注冊實例.
     */
    beanFactory.registerSingleton(ConfigValueBeanPostProcessor.class.getName(),
            new ConfigValueBeanPostProcessor(beanFactory));
}
 
開發者ID:kevin70,項目名稱:setaria,代碼行數:21,代碼來源:ConfigValueBeanFactoryPostProcessor.java

示例7: getPlaceholderConfigurerResources

import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; //導入依賴的package包/類
public Optional<Resource[]> getPlaceholderConfigurerResources() {

        List<Resource> resources = Lists.newArrayList();
        Iterator<Entry<String, PropertySourcesPlaceholderConfigurer>> iterator = placeholderMap.entrySet().iterator();
        while (iterator.hasNext()) {
            Entry<String, PropertySourcesPlaceholderConfigurer> entry = iterator.next();
            Optional<Resource[]> optional = this.<Resource[]> getPropertyValue(entry.getValue(),
                PropertySourcesEnum.LOCATIONS.getName());

            if (optional.isPresent()) {
                resources.addAll(Arrays.asList(optional.get()));
            }
        }

        return Optional.fromNullable(resources.toArray(new Resource[0]));
    }
 
開發者ID:ErinDavid,項目名稱:elastic-config,代碼行數:17,代碼來源:PlaceholderResolved.java

示例8: deducePropertySources

import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; //導入依賴的package包/類
private PropertySources deducePropertySources() {
    PropertySourcesPlaceholderConfigurer configurer = getSinglePropertySourcesPlaceholderConfigurer();
    if (configurer != null) {
        // Flatten the sources into a single list so they can be iterated
        return new FlatPropertySources(configurer.getAppliedPropertySources());
    }
    if (this.environment instanceof ConfigurableEnvironment) {
        MutablePropertySources propertySources = ((ConfigurableEnvironment) this.environment)
                .getPropertySources();
        return new FlatPropertySources(propertySources);
    }
    // empty, so not very useful, but fulfils the contract
    return new MutablePropertySources();
}
 
開發者ID:zouzhirong,項目名稱:configx,代碼行數:15,代碼來源:ConfigPropertyResolver.java

示例9: getSinglePropertySourcesPlaceholderConfigurer

import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; //導入依賴的package包/類
private PropertySourcesPlaceholderConfigurer getSinglePropertySourcesPlaceholderConfigurer() {
    // Take care not to cause early instantiation of all FactoryBeans
    if (this.beanFactory instanceof ListableBeanFactory) {
        ListableBeanFactory listableBeanFactory = (ListableBeanFactory) this.beanFactory;
        Map<String, PropertySourcesPlaceholderConfigurer> beans = listableBeanFactory
                .getBeansOfType(PropertySourcesPlaceholderConfigurer.class, false,
                        false);
        if (beans.size() == 1) {
            return beans.values().iterator().next();
        }
    }
    return null;
}
 
開發者ID:zouzhirong,項目名稱:configx,代碼行數:14,代碼來源:ConfigPropertyResolver.java

示例10: properties

import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; //導入依賴的package包/類
@Bean
@Profile("vagrant")
public static PropertySourcesPlaceholderConfigurer properties()
        throws Exception {
    String file = "application-vagrant.properties";
    PropertySourcesPlaceholderConfigurer pspc =
            new PropertySourcesPlaceholderConfigurer();
    pspc.setLocations(getResources(file));
    pspc.setIgnoreUnresolvablePlaceholders(true);
    pspc.setLocalOverride(true);
    return pspc;
}
 
開發者ID:oncecloud,項目名稱:devops-cstack,代碼行數:13,代碼來源:CloudUnitApplicationContext.java

示例11: propertiesForProduction

import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; //導入依賴的package包/類
@Bean
@Profile("production")
public static PropertySourcesPlaceholderConfigurer propertiesForProduction()
        throws Exception {
    String file = "application-production.properties";
    PropertySourcesPlaceholderConfigurer pspc =
            new PropertySourcesPlaceholderConfigurer();
    pspc.setLocations(getResources(file));
    pspc.setIgnoreUnresolvablePlaceholders(true);
    pspc.setLocalOverride(true);
    return pspc;
}
 
開發者ID:oncecloud,項目名稱:devops-cstack,代碼行數:13,代碼來源:CloudUnitApplicationContext.java

示例12: propertiesForDemo

import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; //導入依賴的package包/類
@Bean
@Profile("vagrant-demo")
public static PropertySourcesPlaceholderConfigurer propertiesForDemo()
        throws Exception {
    String file = "application-vagrant-demo.properties";
    PropertySourcesPlaceholderConfigurer pspc =
            new PropertySourcesPlaceholderConfigurer();
    pspc.setLocations(getResources(file));
    pspc.setIgnoreUnresolvablePlaceholders(true);
    pspc.setLocalOverride(true);
    return pspc;
}
 
開發者ID:oncecloud,項目名稱:devops-cstack,代碼行數:13,代碼來源:CloudUnitApplicationContext.java

示例13: propertiesForTest

import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; //導入依賴的package包/類
@Bean
@Profile("test")
public static PropertySourcesPlaceholderConfigurer propertiesForTest()
        throws Exception {
    PropertySourcesPlaceholderConfigurer pspc =
            new PropertySourcesPlaceholderConfigurer();
    Resource[] resources = new Resource[]
            {new ClassPathResource("application-test.properties")};
    pspc.setLocations(resources);
    pspc.setIgnoreUnresolvablePlaceholders(true);
    pspc.setLocalOverride(true);
    return pspc;
}
 
開發者ID:oncecloud,項目名稱:devops-cstack,代碼行數:14,代碼來源:CloudUnitApplicationContext.java

示例14: properties

import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; //導入依賴的package包/類
@Bean
public static PropertySourcesPlaceholderConfigurer properties()
{
    PropertySourcesPlaceholderConfigurer propertySources = new PropertySourcesPlaceholderConfigurer();
    //propertySources.setIgnoreUnresolvablePlaceholders(true);
    return propertySources;
}
 
開發者ID:scrumtracker,項目名稱:scrumtracker2017,代碼行數:8,代碼來源:ApplicationContext.java

示例15: properties

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

}
 
開發者ID:murugan425,項目名稱:learn-spring-5,代碼行數:8,代碼來源:PropertyConfig.java


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