Is there a way in spring boot to merge properties from different config files and start the application?
Ex: My application-local.yml which is the one that gets used by default had following properties
server:
port: 8080
spring:
profiles: local
propertyA: xxx
propertyB: yyy
Now instead of having to copy all the properties from the local to lets say application-QA.yml like this
server:
port: 8081
spring:
profiles: local
propertyA: xxx
propertyB: zzz
where only port & propertyB has been updated, can I just have something like below?
application-QA.yml:
server:
port: 8081
propertyB: zzz
At the end I want to have the following ability to start my applicatio
Right now we have to copy port & propertyB to application-local.yml and start the application in order to point to QA environment and I would like to eliminate that.
Note: ./gradlew bootrun -Dspring.profiles.active=QA doesn't seem to work for me since I will need all the properties in application-local.yml to be in application-QA.yml and not just the properties I want to override.
You can do this using spring profiles. You can activate many profiles together and every profile will read properties from an additional application-.yml
So you set the common properties in application-local.yml, and only the different ones e.g. the port in application-QA.yml .
You activate both profiles together with
-Dspring.profiles.active=local,QA
See also spring howto-properties-and-configuration
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With