您当前的位置:首页 > 计算机 > 系统应用 > Linux

linux系统下解压war包

时间:04-12来源:作者:点击数:

网上很多人说用jar包解压,但jar命令解压时不能指定目录,推荐使用unzip解压war包。

Linux系统中先检查是否可用unzip命令

[root@VM_83_104_centos ~]# unzip --help
-bash: unzip: command not found

需要先自行下载:yum install zip unzip

[root@VM_83_104_centos ~]# yum install zip unzip
Loaded plugins: fastestmirror, langpacks
epel                                                                                                                                                                    | 4.3 kB  00:00:00
extras                                                                                                                                                                  | 3.4 kB  00:00:00
mysql-connectors-community                                                                                                                                              | 2.5 kB  00:00:00
mysql-tools-community                                                                                                                                                   | 2.5 kB  00:00:00
mysql56-community                                                                                                                                                       | 2.5 kB  00:00:00
os                                                                                                                                                                      | 3.6 kB  00:00:00
updates                                                                                                                                                                 | 3.4 kB  00:00:00
(1/3): epel/7/x86_64/group_gz                                                                                                                                           | 170 kB  00:00:00
(2/3): epel/7/x86_64/updateinfo                                                                                                                                         | 673 kB  00:00:00
(3/3): epel/7/x86_64/primary_db                                                                                                                                         | 4.3 MB  00:00:00
Loading mirror speeds from cached hostfile
Package zip-3.0-10.el7.x86_64 already installed and latest version
Package unzip-6.0-15.el7.x86_64 already installed and latest version
Nothing to do

查看unzip命令的帮助

[root@VM_83_104_centos ~]# unzip --help
UnZip 6.00 of 20 April 2009, by Info-ZIP.  Maintained by C. Spieler.  Send
bug reports using http://www.info-zip.org/zip-bug.html; see README for details.

Usage: unzip [-Z] [-opts[modifiers]] file[.zip] [list] [-x xlist] [-d exdir]
  Default action is to extract files in list, except those in xlist, to exdir;
  file[.zip] may be a wildcard.  -Z => ZipInfo mode ("unzip -Z" for usage).

  -p  extract files to pipe, no messages     -l  list files (short format)
  -f  freshen existing files, create none    -t  test compressed archive data
  -u  update files, create if necessary      -z  display archive comment only
  -v  list verbosely/show version info       -T  timestamp archive to latest
  -x  exclude files that follow (in xlist)   -d  extract files into exdir
modifiers:
  -n  never overwrite existing files         -q  quiet mode (-qq => quieter)
  -o  overwrite files WITHOUT prompting      -a  auto-convert any text files
  -j  junk paths (do not make directories)   -aa treat ALL files as text
  -U  use escapes for all non-ASCII Unicode  -UU ignore any Unicode fields
  -C  match filenames case-insensitively     -L  make (some) names lowercase
  -X  restore UID/GID info                   -V  retain VMS version numbers
  -K  keep setuid/setgid/tacky permissions   -M  pipe through "more" pager
See "unzip -hh" or unzip.txt for more help.  Examples:
  unzip data1 -x joe   => extract all files except joe from zipfile data1.zip
  unzip -p foo | more  => send contents of foo.zip via pipe into program more
  unzip -fo foo ReadMe => quietly replace existing ReadMe if archive file newer
[root@VM_83_104_centos ~]#

需要用到的指令:-o: -q:

-o overwrite files WITHOUT prompting:不必先询问用户,unzip执行后覆盖原有文件。

-q quiet mode (-qq => quieter):执行时不显示任何信息(静默)。

-dextractfilesintoexdir:把压缩文件解压到指定目录下

解压war文件到指定目录:将test.war文件解压到test目录下=unzip -oq test.war -d test

最后附上一个通过jar命令操作war包的方式:

压缩war包,把当前目录下的所有文件打包到xxx.war:jar -cvfM0 xxx.war ./

-c   创建war包
-v   显示过程信息
-f    
-M
-0   这个是阿拉伯数字,只打包不压缩的意思

解压war包,解压xxx.war到当前目录:jar -xvf game.war

方便获取更多学习、工作、生活信息请关注本站微信公众号城东书院 微信服务号城东书院 微信订阅号
推荐内容
相关内容
栏目更新
栏目热门