怎么使用 graalvm-jdk 打包成可执行文件呢?

Blade 未结 2 235

我想使用 graalvm-jdk-17.0.11+7.1 本地打包成.exe可执行文件,怎么配置呢?

2条回答
  • 2024-09-10 11:15
    0 讨论(0)
  • 2024-09-19 18:30

    我在 pom.xml 文件增加如下配置

    <profiles>
        <profile>
            <id>native</id>
            <properties>
                <java.version>17</java.version>
                <maven.compiler.source>17</maven.compiler.source>
                <maven.compiler.target>17</maven.compiler.target>
                <maven.compiler.compilerVersion>17</maven.compiler.compilerVersion>
                <maven.compiler.encoding>UTF-8</maven.compiler.encoding>
                <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
                <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
                <downloadSources>false</downloadSources>
                <downloadJavadocs>false</downloadJavadocs>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.graalvm.buildtools</groupId>
                        <artifactId>native-maven-plugin</artifactId>
                        <version>0.10.2</version>
                        <extensions>true</extensions>
                        <configuration>
                            <imageName>blade-api</imageName>
                            <mainClass>org.springblade.Application</mainClass>
                            <useArgFile>true</useArgFile>
                            <fallback>false</fallback>
                            <skipNativeTests>true</skipNativeTests>
                            <skipTests>true</skipTests>
                            <debug>true</debug>
                            <verbose>true</verbose>
                        </configuration>
                        <executions>
                            <execution>
                                <id>build-native</id>
                                <goals>
                                    <goal>compile-no-fork</goal>
                                </goals>
                                <phase>package</phase>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    打开 x64 Native Tools Command Prompt for VS 2022 终端,输入如下命令

    mklink /J D:\J D:\Developer\GraalVM\graalvm-jdk-17.0.11+7.1
    set JAVA_HOME=D:\J
    set PATH=%JAVA_HOME%\bin;%PATH%
    cd /d D:\Documents\IdeaProjects\cipher-service\bladex-boot
    mvn clean package -DskipTests=true -Pnative

    报错如下图,请问该怎么处理?

    image.png

    0 讨论(0)
提交回复