I have a library that is a Spring Boot project. The library has a library.yml file that contains dev and prod props for its configuration:
library.yml
---
spring:
profiles:
active: dev
---
spring:
profiles: dev
env: dev
---
spring:
profiles: prod
env: prod
Another application uses this library and loads the props using:
@Bean
public static PropertySourcesPlaceholderConfigurer dataProperties() {
PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer = new PropertySourcesPlaceholderConfigurer();
YamlPropertiesFactoryBean yaml = new YamlPropertiesFactoryBean();
yaml.setResources(new ClassPathResource("library.yml"));
propertySourcesPlaceholderConfigurer.setProperties(yaml.getObject());
return propertySourcesPlaceholderConfigurer;
}
And its application.yml says to use dev props:
---
spring:
profiles:
active: dev
But when I check the value of env, I get "prod". Why?
How can I tell Spring Boot to use the active (e.g. dev) profile props in library.yml?
Note: I prefer to use .yml instead .properties files.