After the jar package is decompressed, modify the configuration file, and then restore it to the jar package

Windows system and mac laptop have the same commands as
mac computer: you need to enter the directory where the jar package is located,
generally:
open the terminal, cd ~/desktop This is the directory of the jar package file on the desktop

After the jar package is decompressed, modify the configuration file, and then restore it to the jar package;

There are many variables in the project that will be written in configuration files such as xml and properties under the resources folder. When these files need to be modified, it will be very troublesome if they are modified locally and then packaged and uploaded to the server. Because the configuration file does not need to be compiled into a class like a java file, it can be directly modified after decompressing the jar package on the server, and then compressed and restored into a jar package.

Take the Springboot project as an example

1. Unzip

jar -xvf xxx.jar

After decompression, three folders will be generated: BOOT-INF/ META-INF/ org/
insert image description here
2. Modify the configuration file under BOOT-INF\classes
insert image description here
3. After modification, return to the root directory and recompress

jar -cvfM0 xxx.jar BOOT-INF/ META-INF/ org/

Guess you like

Origin blog.csdn.net/xingchen678/article/details/122473514