How to edit the content of an application.properties or application.yml file inside an existing jar on a remote Linux server
A .jar
file is simply a .zip
file with a different extension, and vim
can edit zip files and their contents directly! Simply vim
your .jar
, use the file navigator to find your properties file and change it. vim
will maintain the zip with your edits.
See here for more details.
Possible route could be to copy the jar into a zip file, extract, change your properties, compress to zip and rename to jar
cp myJar.jar myJar.zip
unzip myJar.zip
vim myProperties.properties (doing the change here)
zip allMyFiles into myJar.zip
cp myJar.zip myModifiedJar.jar
Changing an existing JAR artifact is not a good idea. Instead, Spring Boot allows you to easily override the bundled properties with external values in several ways.
For example you can place an application.properties
file next to the JAR with the values that you want to override. You don't even need to copy the whole properties file there, only the properties you want to change, because it still falls back to the bundled defaults.
The details are documented here:
https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html