简体   繁体   中英

How to modify Spring Boot bootRepackage jar file?

I want to modify application.properties of a jar file after build a spring boot application. I had used jar xf to extract the jar file then modified the properties file but after jar-ed ( jar -0cf ), it had not been working with printout:

no main manifest attribute, in < filename >.jar

So is there anyway to do it and how?

Jar file is just an zip file. You can open it and add file using any of tools that manipulate zip files.

Or if you want to update using jar command line you can do it using this syntax.

jar uf jar-file input-file(s)

Like described here:

https://docs.oracle.com/javase/tutorial/deployment/jar/update.html

Another Solution:

You can override the application.properties by the --spring.config.location as the below:

java -jar /path-to-jar-file/jarFileName.jar --spring.config.location=/path-to-propertiesFile/application.properties


This way you can easily update the application.properties.
It is useful when you want to run your jar file with java -jar command line (for example run jar file as a service in the Linux).

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