简体   繁体   中英

Add external properties file packaging war Spring Boot

I have .properties file with secured information such as database password ,username and so on, this file locate outside of src/resources folder. Is it possible to add this file to war file on packaging step

Like:

mvn clean package -DAddResource=/home/user/secured.properties

Two possible solutuions: 1) As I use jenkins , it's possible to use File Plugin , which dynamically add new file to your project 2) Second one , and this is the worst one , you can add spring property location directly to Tomcat in setenv.sh

JAVA_OPTS="$JAVA_OPTS -Dspring.config.location=/home/site/site/site.properties"

The main disadvantage is this file will be the same for all wars you deploy inside Tomcat

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