How to set @PropertySource with value read from VM argument maven spring boot
The VM options that I use -Dprofile.active=t1
To run the application : mvn exec: java -Dprofile.active=t1
My intention is to make use of the profile.active value to dynamically select the properties file.
In order to resolve ${...} placeholders in definitions or @Value annotations using properties from a PropertySource, one must register a PropertySourcesPlaceholderConfigure
The VM options that I use -Dprofile.active=t1
To run the application : mvn exec: java -Dprofile.active=t1
My intention is to make use of the profile.active value to dynamically select the properties file.
In order to resolve ${...} placeholders in definitions or @Value annotations using properties from a PropertySource, one must register a PropertySourcesPlaceholderConfigure
@SpringBootApplication@PropertySource
("classpath:/conf/${profile.active}.properties") public class SpringExternalWsApplication { public static void main(String[] args) { //Setting the default properties
propertySourcesPlaceholderConfigurer().setProperties(System.getProperties());SpringApplication.run(SpringExternalWsApplication.class, args); } @Bean public static PropertySourcesPlaceholderConfigurer
propertySourcesPlaceholderConfigurer() { PropertySourcesPlaceholderConfigurer
propertySourcesPlaceholderConfigurer = new
PropertySourcesPlaceholderConfigurer();
return propertySourcesPlaceholderConfigurer; } }
No comments:
Post a Comment