可通过以下网址获得演示项目:https://github.com/codependent/micronaut-graal-hello-world
我已经按照https://docs.micronaut.io/1.1.0.M1/guide/index.html#graalServices
上的说明创建了一个基本的Micronaut应用程序。使用随附的脚本./build-native-image.sh
创建后,我启动./micronaut-graal-hello-world
从我在外壳中启动映像的那一刻起,大约需要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