Spring Boot开启AOT的方式运行

Spring Boot支持对AOT模式的启动、测试

1、构建

mvn -Pnative native:compile

mvn -Pnative spring-boot:build-image

1、启用AOT的方式启动app

java -Dspring.aot.enabled=true -jar myapp.jar

作用:在进行GraalVM Native构建前检查是否存在有AOT未注册hints,以减少native image构建时的异常

2、AOT演练

java -Dspring.aot.enabled=true \
    -agentlib:native-image-agent=config-output-dir=/path/to/config-dir/ \
    -jar target/myapp.jar

3、以AOT的方式运行单元测试

mvn -PnativeTest test

4、更多资料, 见

https://docs.spring.io/spring-boot/docs/3.2.6/reference/html/native-image.html#native-image
https://docs.spring.io/spring-framework/reference/core/aot.html

posted @ 2024-06-05 15:50  漠孤烟  阅读(873)  评论(0)    收藏  举报