Search in sources :

Example 1 with PropertySourcesPlaceholderConfigurer

use of org.springframework.context.support.PropertySourcesPlaceholderConfigurer in project spring-boot by spring-projects.

the class ConfigurationPropertiesBindingPostProcessor method deducePropertySources.

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
    logger.warn("Unable to obtain PropertySources from " + "PropertySourcesPlaceholderConfigurer or Environment");
    return new MutablePropertySources();
}
Also used : ConfigurableEnvironment(org.springframework.core.env.ConfigurableEnvironment) PropertySourcesPlaceholderConfigurer(org.springframework.context.support.PropertySourcesPlaceholderConfigurer) MutablePropertySources(org.springframework.core.env.MutablePropertySources)

Example 2 with PropertySourcesPlaceholderConfigurer

use of org.springframework.context.support.PropertySourcesPlaceholderConfigurer in project gravitee-management-rest-api by gravitee-io.

the class RestConfiguration method properties.

@Bean
public static PropertySourcesPlaceholderConfigurer properties(@Qualifier("graviteeProperties") Properties graviteeProperties) {
    PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer = new PropertySourcesPlaceholderConfigurer();
    propertySourcesPlaceholderConfigurer.setProperties(graviteeProperties);
    propertySourcesPlaceholderConfigurer.setIgnoreUnresolvablePlaceholders(true);
    return propertySourcesPlaceholderConfigurer;
}
Also used : PropertySourcesPlaceholderConfigurer(org.springframework.context.support.PropertySourcesPlaceholderConfigurer) Bean(org.springframework.context.annotation.Bean)

Example 3 with PropertySourcesPlaceholderConfigurer

use of org.springframework.context.support.PropertySourcesPlaceholderConfigurer in project tutorials by eugenp.

the class WebConfig method propertySourcesPlaceholderConfigurer.

// beans
@Bean
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
    final PropertySourcesPlaceholderConfigurer ppc = new PropertySourcesPlaceholderConfigurer();
    ppc.setIgnoreUnresolvablePlaceholders(true);
    return ppc;
}
Also used : PropertySourcesPlaceholderConfigurer(org.springframework.context.support.PropertySourcesPlaceholderConfigurer) Bean(org.springframework.context.annotation.Bean)

Example 4 with PropertySourcesPlaceholderConfigurer

use of org.springframework.context.support.PropertySourcesPlaceholderConfigurer in project tutorials by eugenp.

the class ServiceConfig method propertySourcesPlaceholderConfigurer.

// beans
@Bean
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
    final PropertySourcesPlaceholderConfigurer ppc = new PropertySourcesPlaceholderConfigurer();
    ppc.setIgnoreUnresolvablePlaceholders(true);
    return ppc;
}
Also used : PropertySourcesPlaceholderConfigurer(org.springframework.context.support.PropertySourcesPlaceholderConfigurer) Bean(org.springframework.context.annotation.Bean)

Example 5 with PropertySourcesPlaceholderConfigurer

use of org.springframework.context.support.PropertySourcesPlaceholderConfigurer in project ma-core-public by infiniteautomation.

the class MangoRestSpringConfiguration method propertySourcesPlaceholderConfigurer.

/**
 * TODO EXPERIMENTAL SUPPORT FOR PROPERTY CONFIGURATION IN ANNOTATIONS Setup
 * properties to be used in the Spring templates
 *
 * @return
 */
@Bean
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
    // note the static method! important!!
    PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer();
    Resource[] resources = new ClassPathResource[] { new ClassPathResource("env.properties") };
    configurer.setLocations(resources);
    configurer.setIgnoreUnresolvablePlaceholders(true);
    // Create and add any properties for Spring Annotations
    Properties properties = new Properties();
    configurer.setProperties(properties);
    return configurer;
}
Also used : ClassPathResource(org.springframework.core.io.ClassPathResource) Resource(org.springframework.core.io.Resource) PropertySourcesPlaceholderConfigurer(org.springframework.context.support.PropertySourcesPlaceholderConfigurer) Properties(java.util.Properties) ClassPathResource(org.springframework.core.io.ClassPathResource) Bean(org.springframework.context.annotation.Bean)

Aggregations

PropertySourcesPlaceholderConfigurer (org.springframework.context.support.PropertySourcesPlaceholderConfigurer)29 Bean (org.springframework.context.annotation.Bean)18 ClassPathResource (org.springframework.core.io.ClassPathResource)7 Properties (java.util.Properties)5 YamlPropertiesFactoryBean (org.springframework.beans.factory.config.YamlPropertiesFactoryBean)4 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)3 Resource (org.springframework.core.io.Resource)3 ConfigurableEnvironment (org.springframework.core.env.ConfigurableEnvironment)2 MutablePropertySources (org.springframework.core.env.MutablePropertySources)2 FileSystemResource (org.springframework.core.io.FileSystemResource)2 JndiPropertySource (org.springframework.jndi.JndiPropertySource)2 ArchaiusSpringPropertySource (com.kixeye.chassis.bootstrap.spring.ArchaiusSpringPropertySource)1 SpringEnvironmentProperties (com.thinkbiganalytics.spring.SpringEnvironmentProperties)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 PrintWriter (java.io.PrintWriter)1 lombok.val (lombok.val)1 CasServerProperties (org.apereo.cas.configuration.model.core.CasServerProperties)1 ReloadablePropertySource (org.finra.herd.dao.ReloadablePropertySource)1 Test (org.junit.jupiter.api.Test)1 MutablePropertyValues (org.springframework.beans.MutablePropertyValues)1