fatjar添加jar包的方式
问题:在技术支持中遇到过以下问题,需要注意:
用户在pinpoint的fatjar中通过压缩工具打开jar包,然后拖放pinpoint-apusic-plugin-2.1.3-SNAPSHOT.jar这个插件进去之后,通过 java -jar 启动fatjar时候,报以下错误:
Exception in thread "main" java.lang.IllegalStateException: Failed to get nested archive for entry BOOT-INF/L1b/pinpoint-apusic-plugin-2.1.3-SNAPSHOT.jar
at ors.springframework.boot.loader.archive.JarfileArchivesnetozkrihrvolverszof.lsapchavr-/Arvai2hile.jova:26)
at org.springframework.boot.loader.archive.JarFileArchive$NestedArchiveIterator.adapt(JarFileArchive.java:227)
at org.springframework.boot.loader.archive.JarFileArchive$AbstractIterator.next(JarFileArchive.java:188)
at org.springframework.boot.loader.ExecutableArchiveLauncher.createClassLoader(ExecutableArchiveLauncher.java:87)
at org.springframework.boot.loader.Launcher.Taunch(Launcher.java:55)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88)
Caused by: java.o.I0Exception: Unable to open nested jar file 'BOOT-INF/Lib/pinpoint-apusic-plugin-2.1.3-SNAPSHOT.jar
at org.springframework.boot.loader.jar.JarFile.getNestedJarFile(JarFile.java:304)
at org.springframework.boot.loader.jar.JarFile.getNestedJarFile(JarFile.java:290)
at org-springframework.boot.loader.archive.JarFileArchive.petHlestedArchive(JarF11eArchive.java:991
Caused by: java.lang.IllegalStateException: Unable to open nested entry 'BOOT-INF/lib/pinpoint-apusic-plugin-2.1.3-SNAPSHOT.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:331)
at org.springframework.boot.loader.jar.JarFile.createJarFileFromEntry(JarFile.java:312)
at org.springframework.boot.loader.jar.JarFile.getNestedJarFile(JarFile.java:301)
解决:
需要先解压fatjar,然后添加新的jar包进去后,再进行打包。
1. jar -xvf xxx.jar
2. jar -cvfM0 xxx.jar -C xxx/ .