首先,我知道使用命令行中的jar 解压缩WAR文件是可能的。
问题是,在目标机器上,没有安装JDK,只有JRE。而且我们不能依靠Windows来解压缩文件,因为它不支持很长的路径。
如果您只安装了JRE,如何在命令行中解压缩WAR文件?
发布于 2016-04-22 20:18:47
为了记录在案,我将分享我从这个回答中得到的解决方案。
我在我的问题中指出,我还有一个长路径问题,一个我用新PSDrive解决的问题,一个函数,它允许映射一个临时驱动器。我只将一个临时驱动器映射到我解压缩东西的工作文件夹上。
function Unzip-File($file) {
$path = [io.path]::GetDirectoryName($file.FullName)
$filename = [io.path]::GetFileNameWithoutExtension($file.FullName)
$targetPath = Join-Path $path $filename;
# Check if the directory exists.
if(Test-Path $targetPath) {
# Remove the directory before unzipping.
Remove-Item $targetPath -recurse
}
# Unzip file.
Add-Type -A System.IO.Compression.FileSystem
[IO.Compression.ZipFile]::ExtractToDirectory($file, $targetPath)
}发布于 2016-04-19 15:12:29
WAR文件只是一个ZIP文件,您可以使用任何Zip工具(如7-Zip)解压缩它。如果您没有访问管理帐户,您可以下载任何压缩存档的便携版,这不需要管理密码。
https://stackoverflow.com/questions/36721643
复制相似问题