I have a Spring Boot multi-module maven project. I want my library module to handle its own properties.
So, in the library module:
src/java/resources/module-name/application.properties
src/java/resources/module-name/application-dev.properties
src/java/resources/module-name/application-prod.properties
I have a @Configuration
class in that module with:
@PropertySource("classpath://module-name/application-dev.properties")
Obviously, this will only load the dev
properties.
2 Questions:
1) How do I factor in @Profile
in here so I don't have to create multiple configuration classes, each with its own @Profile
. Is there a way to combine the annotations or parameterize them with something like application-${spring.active.profile}.properties
?
2) How do I achieve the same behavior vis-a-vis application.properties
file as I would have out of the box if these files were in the root of the classpath and picked up automatically by Spring? In other words, I'd like to place all the common properties into application.properties
file and only the profile specific ones into application-dev.properties
or application-prod.properties
ones.