Externalizing Properties so that deployment doesn't require code compilation

349 views Asked by At

Working on spring-boot application where we are keeping properties for different environments in different properties files like for prod its application-prod.properties, for uat it's application-uat.properties, etc. These properties files resides under src/main/resources/ folder. For running in different environment we pass env as parameter on command line and spring-boot takes up correct properties file. We are using teamcity for automatic deployment.

The problem is whenever a property is changed we need to compile and build application a again as properties file resides with the code. How can I pass property file or better it's path in the build step of teamcity so that with each change in a property just restarting the application with new property will be suffice without recompiling the whole application. Also how to deal this at local level i.e. for local running of the application with different properties file.

1

There are 1 answers

0
boden On

You can pass property file as parameter during application start. The following example shows how to specify two locations:

java -jar myproject.jar --spring.config.location=classpath:/default.properties,classpath:/override.properties

Application Property Files