演示项目位于:https ://github.com/codependent/micronaut-graal-hello-world
我按照以下说明创建了一个基本的 Micronaut 应用程序:https ://docs.micronaut.io/1.1.0.M1/guide/index.html#graalServices
使用包含的脚本可以很好地生成本机图像./build-native-image.sh
创建后我启动./micronaut-graal-hello-world
从我在 shell 中启动图像的那一刻起,大约需要 30 秒来记录:19:26:15.113 [main] INFO io.micronaut.runtime.Micronaut - Startup completed in 19ms. Server Running: http://localhost:8080
因此,Micronaut 应用程序启动得非常快(19 毫秒!!),但启动图像需要 30 秒。这怎么可能?这使得使用 GraalVM 图像毫无意义,因为进程的启动时间太慢。
注意我的环境是 MacOS Mojave