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