简体   繁体   中英

Externalizing Properties so that deployment doesn't require code compilation

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 ie for local running of the application with different properties file.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM