我试图通过本机映像执行以下命令来编译SpringBoot应用程序本机映像—没有回退—jarrest.jar所有编译都很好,但在运行时我看到了一个异常
Exception in thread "main" java.lang.IllegalStateException: java.util.zip.ZipException: zip END header not found
at org.springframework.boot.loader.ExecutableArchiveLauncher.<init>(ExecutableArchiveLauncher.java:52)
at org.springframework.boot.loader.JarLauncher.<init>(JarLauncher.java:48)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88)
Caused by: java.util.zip.ZipException: zip END header not found
at java.util.zip.ZipFile$Source.zerror(ZipFile.java:1581)
at java.util.zip.ZipFile$Source.findEND(ZipFile.java:1476)
at java.util.zip.ZipFile$Source.initCEN(ZipFile.java:1483)
at java.util.zip.ZipFile$Source.<init>(ZipFile.java:1288)
at java.util.zip.ZipFile$Source.get(ZipFile.java:1251)
at java.util.zip.ZipFile$CleanableResource.<init>(ZipFile.java:732)
at java.util.zip.ZipFile$CleanableResource.get(ZipFile.java:849)
at java.util.zip.ZipFile.<init>(ZipFile.java:247)
at java.util.zip.ZipFile.<init>(ZipFile.java:177)
at java.util.jar.JarFile.<init>(JarFile.java:348)
at java.util.jar.JarFile.<init>(JarFile.java:319)
at java.util.jar.JarFile.<init>(JarFile.java:285)
at org.springframework.boot.loader.jar.AbstractJarFile.<init>(AbstractJarFile.java:39)
at org.springframework.boot.loader.jar.JarFile.<init>(JarFile.java:128)
at org.springframework.boot.loader.jar.JarFile.<init>(JarFile.java:123)
at org.springframework.boot.loader.jar.JarFile.<init>(JarFile.java:109)
at org.springframework.boot.loader.jar.JarFile.<init>(JarFile.java:100)
at org.springframework.boot.loader.archive.JarFileArchive.<init>(JarFileArchive.java:57)
at org.springframework.boot.loader.archive.JarFileArchive.<init>(JarFileArchive.java:53)
at org.springframework.boot.loader.Launcher.createArchive(Launcher.java:162)
at org.springframework.boot.loader.ExecutableArchiveLauncher.<init>(ExecutableArchiveLauncher.java:48)
我做错了什么?
1条答案
按热度按时间svgewumm1#
当您通过本机映像从fatjar编译二进制文件时,它会从清单中获取主类:org.springframework.boot.loader.jarlauncher,并尝试使用入口点jarlauncher生成可执行二进制文件。然后运行编译过的二进制文件,尝试打开自己作为zip存档读取并抛出zipexception。试试这个https://spring.io/blog/2020/04/16/spring-tips-the-graalvm-native-image-builder-feature