Maven 插件的提前处理
原文:https://docs.spring.io/spring-boot/maven-plugin/aot.html (Spring Boot 4.2.0)
处理应用
使用 Native Profile
Spring Boot 的 Maven 插件提供 native profile,激活后会配置 AOT 处理和原生镜像构建。使用 -Pnative 激活。
spring-boot:process-aot 目标
在应用上调用 AOT 引擎。常用参数:
arguments(String[]):传递给 AOT 引擎的参数。classesDirectory(File):包含类文件的目录。compilerArguments(String):编译器参数。excludeGroupIds(String[]):从 AOT 处理中排除的 group ID。generatorOutputDirectory(File):生成源代码的输出目录。mainClass(String):应用主类。profiles(String[]):构建时激活的 profile。
spring-boot:process-test-aot 目标
在测试上调用 AOT 引擎,参数与 process-aot 类似。
AOT 处理会在构建时评估条件并生成 bean 定义的持久化视图,这意味着在构建时设置的 profile 和属性会影响运行时行为。