jar打包命令使用

 今天老版本項目出了個bug,當時svn上沒有打分支,因而反編譯了一下,找到相應幾個要修改的文件,修改後替換進去,發現啓動失敗(Spring boot項目)提示java

Exception in thread "main" java.lang.IllegalStateException: Unable to open nested entry 'BOOT-INF/lib/antlr-2.7.7.jar'. It has been compressed and nested jar files must be stored without compression. Please check the mechanism used to create your executable jar file
PS E:\pwd0508\b2b-erp> java -jar .\b2b-erp.jar
Exception in thread "main" java.lang.IllegalStateException: Unable to open nested entry 'BOOT-INF/lib/antlr-2.7.7.jar'.
It has been compressed and nested jar files must be stored without compression. Please check the mechanism used to create your executable jar file
        at org.springframework.boot.loader.jar.JarFile.createJarFileFromFileEntry(JarFile.java:285)
        at org.springframework.boot.loader.jar.JarFile.createJarFileFromEntry(JarFile.java:260)
        at org.springframework.boot.loader.jar.JarFile.getNestedJarFile(JarFile.java:248)
        at org.springframework.boot.loader.jar.JarFile.getNestedJarFile(JarFile.java:237)
        at org.springframework.boot.loader.archive.JarFileArchive.getNestedArchive(JarFileArchive.java:103)
        at org.springframework.boot.loader.archive.JarFileArchive.getNestedArchives(JarFileArchive.java:87)
        at org.springframework.boot.loader.ExecutableArchiveLauncher.getClassPathArchives(ExecutableArchiveLauncher.java:72)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:49)
        at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:58)

 

提示意思:jar內部依賴的第三方包被壓縮了,看提示是spring的Launcher拋出的,應爲是本身大的包,無法就看了一下jar命令:spring

PS E:\pwd0508\b2b-erp> jar
用法: jar {ctxui}[vfmn0PMe] [jar-file] [manifest-file] [entry-point] [-C dir] files ...
選項:
    -c  建立新檔案
    -t  列出檔案目錄
    -x  從檔案中提取指定的 (或全部) 文件
    -u  更新現有檔案
    -v  在標準輸出中生成詳細輸出
    -f  指定檔案文件名
    -m  包含指定清單文件中的清單信息
    -n  建立新檔案後執行 Pack200 規範化
    -e  爲捆綁到可執行 jar 文件的獨立應用程序
        指定應用程序入口點
    -0  僅存儲; 不使用任何 ZIP 壓縮
    -P  保留文件名中的前導 '/' (絕對路徑) 和 ".." (父目錄) 組件
    -M  不建立條目的清單文件
    -i  爲指定的 jar 文件生成索引信息
    -C  更改成指定的目錄幷包含如下文件
若是任何文件爲目錄, 則對其進行遞歸處理。
清單文件名, 檔案文件名和入口點名稱的指定順序
與 'm', 'f''e' 標記的指定順序相同。

示例 1: 將兩個類文件歸檔到一個名爲 classes.jar 的檔案中:
       jar cvf classes.jar Foo.class Bar.class
示例 2: 使用現有的清單文件 'mymanifest' 並
           將 foo/ 目錄中的全部文件歸檔到 'classes.jar' 中:
       jar cvfm classes.jar mymanifest -C foo/ .

有一個-0的選項,試一下svn

 jar -cvf0m b2b-erp.jar .\META-INF\MANIFEST.MF .

打包成功,執行如下,spring boot圖標出來了  成功!ui

PS E:\pwd0508\b2b-erp> java -jar .\b2b-erp.jar

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.4.1.RELEASE)

2017-05-09 10:09:02 INFO  [main] com.qiaomai.erp.Application.logStarting:48 - Starting Application v1.2.0 on PC201608251
259 with PID 13664 (E:\pwd0508\b2b-erp\b2b-erp.jar started by Administrator in E:\pwd0508\b2b-erp)
2017-05-09 10:09:02 INFO  [main] com.qiaomai.erp.Application.logStartupProfileInfo:665 - The following profiles are acti
ve: dev
2017-05-09 10:09:02 INFO  [main] org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext
.prepareRefresh:581 - Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext
@5eb5c224: startup date [Tue May 09 10:09:02 CST 2017]; root of context hierarchy
2017-05-09 10:09:03 INFO  [background-preinit] org.hibernate.validator.internal.util.Version.<clinit>:30 - HV000001: Hib
ernate Validator 5.2.4.Final
相關文章
相關標籤/搜索