Modify the configuration file in the jar package directly in linux

When some files are uploaded to the server for debugging, you can modify the contents of the jar package directly on the server in order to facilitate modification, and you do not need to upload them every time. 

method one:

1.直接使用 vim xxx.jar
2.找到对应的那个文件回车
3.然后编辑保存后,退出当前目录,退出上层目录

Way two:

(1)使用jar tvf jar名称 | grep 目标文件名 查询出目标文件在jar包中的目录
jar tvf service-0.0.1-SNAPSHOT.jar |grep config.properties

(2)使用jar xvf jar名称 目标文件名(copy上面查出的全路径) 将目标文件及所在jar包中的目录解压到当前路径
jar xvf service-0.0.1-SNAPSHOT.jar BOOT-INF/classes/config/config.properties

(3)修改目标文件的内容,或者将要新的目标文件替换掉提取出来的目标文件
vim BOOT-INF/classes/config/config.properties
或
cp config/config.properties BOOT-INF/classes/config/config.properties

(4)使用jar uvf jar名称 目标文件名(和步骤(2)中的目标文件名相同) 将新目标文件替换到jar包中
jar uvf service-0.0.1-SNAPSHOT.jar BOOT-INF/classes/config/config.properties

 

Guess you like

Origin blog.csdn.net/Baron_ND/article/details/114915895