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?
--spring.config.locationor--spring.config-additional-locationinstead of trying this. See the documentation on how to load additional files. - M. Deinum