0
votes

I have few property files(application.properties) which contains both custom and spring configuration under classpath, i want load these properties based on system variables. I used PropertySourcesPlaceholderConfigurer to load properties as below.

@Bean
    public PropertySourcesPlaceholderConfigurer loadResources() {
PropertySourcesPlaceholderConfigurer resourceConfigurer = new PropertySourcesPlaceholderConfigurer();
        resourceConfigurer.setLocations(new ClassPathResource("file1"), new ClassPathResource("file2"));
return resourceConfigurer ;
}
        

But it failed to override spring configuration(spring configurations added in application.properties), i want to override these files after spring picks application.properties file. Idea is to override spring configuration programmatically. How this can be achieved?

1
Why? This will add only additional processing to the application and indeed will not override things (it might even break the Spring Boot processing). Run the application with --spring.config.location or --spring.config-additional-location instead of trying this. See the documentation on how to load additional files. - M. Deinum

1 Answers

0
votes

I was able to achieve above using EnvironmentPostProcessor.

spring doc