Let\'s say I have 5 Spring Boot Projects. All of them have a Maven dependency on a Spring Boot project No 6 with some shared/common classes. 5 independent projects have a lo
Use PropertySource annotation and provide two sources for your app:
@PropertySources({
@PropertySource("classpath:app-common.properties"),
@PropertySource("classpath:app.properties")
})
more details can be found there https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html
Currently spring boot doesn't provide inheriting properties.
A spring boot application supports multiple property sources but the convention (read: built-in logic) for xxx.properties
is to resolve the last xxx.properties
if there are multiple properties files having the same file name.
There are many solution to this.
One possible solution is to
application-customprofile.properties
spring.profiles.include=customprofile
in application[-{profile}].properties
(note: if set in application.properties
, it applies for all profiles)Another possible solution is to use a unique custom filename for the properties.
application.properties
, use common.properties