准备工作
https://www.graalvm.org/downloads/
解压到一个你熟悉的目录
创建项目
sdk替换
增加一个测试路由
package com.example.graalvm_demo.controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HelloController {
@GetMapping("/hello")
public String hello(){
return "你好 graalVM";
}
}
改下端口
server.port=9888
这是启动时间,现在我们将其打包看一下。
打包
切换jdk
下载
gu install native-image
遇到这种开启代理
set http_proxy=127.0.0.1:7890
打包
mvn -Pnative native:compile
错误
[ERROR] Failed to execute goal org.graalvm.buildtools:native-maven-plugin:0.9.20:compile (default-cli) on project graalvm_demo: Execution of C:\Program Files\Java\graalvm-ce-java17-22.3.1\bin\native-image.cmd @target\tmp\native-image-13827286872102600242.args returned non-zero result -> [Help 1]
标签:web,java,image,体验,org,graalvm,打包,native
From: https://www.cnblogs.com/qiudaozhang/p/17154126.html