Search in sources :

Example 26 with PropertySourcesPlaceholderConfigurer

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

the class ServletWebServerApplicationContextTests method postProcessWebServerFactory.

@Test
void postProcessWebServerFactory() {
    RootBeanDefinition beanDefinition = new RootBeanDefinition(MockServletWebServerFactory.class);
    MutablePropertyValues pv = new MutablePropertyValues();
    pv.add("port", "${port}");
    beanDefinition.setPropertyValues(pv);
    this.context.registerBeanDefinition("webServerFactory", beanDefinition);
    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(getWebServerFactory().getWebServer().getPort()).isEqualTo(8080);
}
Also used : MutablePropertyValues(org.springframework.beans.MutablePropertyValues) RootBeanDefinition(org.springframework.beans.factory.support.RootBeanDefinition) PropertySourcesPlaceholderConfigurer(org.springframework.context.support.PropertySourcesPlaceholderConfigurer) Properties(java.util.Properties) Test(org.junit.jupiter.api.Test)

Example 27 with PropertySourcesPlaceholderConfigurer

use of org.springframework.context.support.PropertySourcesPlaceholderConfigurer in project waltz by khartec.

the class DIConfiguration method propertySourcesPlaceholderConfigurer.

/**
 * Required for property interpolation to work correctly
 * @see <a href="http://stackoverflow.com/a/41760877/2311919">Explanation</a>
 */
@Bean
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer(ConfigurableEnvironment env) {
    PropertySourcesPlaceholderConfigurer placeholderConfigurer = new PropertySourcesPlaceholderConfigurer();
    JndiPropertySource jndiPropertySource = new JndiPropertySource("java:comp");
    env.getPropertySources().addFirst(jndiPropertySource);
    return placeholderConfigurer;
}
Also used : JndiPropertySource(org.springframework.jndi.JndiPropertySource) PropertySourcesPlaceholderConfigurer(org.springframework.context.support.PropertySourcesPlaceholderConfigurer)

Example 28 with PropertySourcesPlaceholderConfigurer

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

the class CommitIdApplication method placeholderConfigurer.

@Bean
public static PropertySourcesPlaceholderConfigurer placeholderConfigurer() {
    PropertySourcesPlaceholderConfigurer c = new PropertySourcesPlaceholderConfigurer();
    c.setLocation(new ClassPathResource("git.properties"));
    c.setIgnoreResourceNotFound(true);
    c.setIgnoreUnresolvablePlaceholders(true);
    return c;
}
Also used : PropertySourcesPlaceholderConfigurer(org.springframework.context.support.PropertySourcesPlaceholderConfigurer) ClassPathResource(org.springframework.core.io.ClassPathResource) Bean(org.springframework.context.annotation.Bean)

Example 29 with PropertySourcesPlaceholderConfigurer

use of org.springframework.context.support.PropertySourcesPlaceholderConfigurer in project gpconnect-demonstrator by nhsconnect.

the class IntegrationTestConfig method propertySourcesPlaceholderConfigurer.

@Bean
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
    PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer = new PropertySourcesPlaceholderConfigurer();
    propertySourcesPlaceholderConfigurer.setIgnoreUnresolvablePlaceholders(true);
    return propertySourcesPlaceholderConfigurer;
}
Also used : PropertySourcesPlaceholderConfigurer(org.springframework.context.support.PropertySourcesPlaceholderConfigurer) 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