文章目录
jar命令
摘要
jar命令
一、引言
jar命令
二、正文内容
2.1 jar解压jar包
shell
\# 解压
jar -xvf test.jar
2.2 重新打成jar包
shell
jar -uvf0 marriage-admin-1.0.0.jar.jar ./*
2.3 步骤
shell
# 1.检索文件
jar -tvf Test-0.0.1-SNAPSHOT.jar | grep Test.class
# 2.取出文件
jar -xvf Test-0.0.1-SNAPSHOT.jar BOOT-INF/classes/com/test/Test.class
#3.替换文件
mv Test.class BOOT-INF/classes/com/test/Test.class
#4.打入jar包
jar -uvf Test-0.0.1-SNAPSHOT.jar BOOT-INF/classes/com/test/Test.class
#5.删除冗余文件
rm -r BOOT-INF
2.4 sh脚本文件
shell
#!/bin/bash
# 动态部署class脚本
className=`ls|grep .class$`
jarName=`ls|grep .jar$`
if [ -z $className ]
then
echo "No class file found."
exit 1
fi
if [ -z $jarName ]
then
echo "No jar file found."
exit 1
fi
echo "The $className is replacing..."
fullPath=`jar -tvf $jarName | grep $className | awk '{print $NF}'`
jar -xvf $jarName $fullPath
mv $className $fullPath
jar -uvf $jarName $fullPath
rm -r BOOT-INF