oracle/graal

ZipException: zip END header not found(Workaround for win11)

Open

#7137 opened on Aug 5, 2023

View on GitHub
 (5 comments) (0 reactions) (1 assignee)Java (21,579 stars) (1,788 forks)batch import
buggood first issuenative-image

Description

Describe the issue

This issue is a workaround to summarize the problem. If your question is as follows

The scenario in which the problem occurs

Upgrade the Spring project's jar first, and then try native-image to generate the exe file

Scene reproduction

mvn package
native-image -jar .\Graalvm-SpringBoot-Demo-0.0.1-SNAPSHOT.jar --no-fallback

You will notice that the exe file appears, but the execution fails image

The way of solve

spring doc:https://docs.spring.io/spring-boot/docs/current/reference/html/native-image.html You can do this successfully with Spring's plugin

<build>
        <plugins>
            <plugin>
                <groupId>org.graalvm.buildtools</groupId>
                <artifactId>native-maven-plugin</artifactId>
                <configuration>
                    <!-- imageName用于设置生成的二进制文件名称 -->
                    <imageName>${project.artifactId}</imageName>
                    <!-- mainClass用于指定main方法类路径 -->
                    <mainClass>${main-class}</mainClass>
                </configuration>
                <executions>
                    <execution>
                        <id>build-native</id>
                        <goals>
                            <goal>compile-no-fork</goal>
                        </goals>
                        <phase>package</phase>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                        </exclude>
                    </excludes>
                </configuration>
            </plugin>
        </plugins>
    </build>
mvn clean package -Pnative

image image image

Contributor guide