graalvm Springboot3 AOT 使用指引

springboot3 AOT技术似乎会与Serverless能更好的结合

搭建环境

  1. 下载graalvm
    graalvm 类似增强版的Jdk,安装方法与jdk完全一致,但是得确认好版本

    GraalVM 目前支持两个java版本: jdk17 与jdk21

    下载地址:GraalVM社区版(注意不是简单的GraalVM-jdk组件)

  2. 配置GraalVM 环境变量

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# 配置JDK路径
export JAVA_8_HOME=/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home
export JAVA_11_HOME=/Library/Java/JavaVirtualMachines/openjdk-11.jdk/Contents/Home
export JAVA_17_HOME=/Library/Java/JavaVirtualMachines/openjdk-17.jdk/Contents/Home
export GRAALVM_17_HOME=/Library/Java/JavaVirtualMachines/graalvm-community-openjdk-17.0.7+7.1/Contents/Home
# 设置默认JDK版本
# export JAVA_HOME=$JAVA_17_HOME
export JAVA_HOME=$GRAALVM_17_HOME
CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:.
# 配置alias命令动态切换JDK版本
alias jdk8="export JAVA_HOME=$JAVA_8_HOME && export PATH=$JAVA_8_HOME/bin/:$PATH"
alias jdk11="export JAVA_HOME=$JAVA_11_HOME && export PATH=$JAVA_11_HOME/bin/:$PATH"
alias jdk17="export JAVA_HOME=$JAVA_17_HOME && export PATH=$JAVA_17_HOME/bin/:$PATH"
alias graal17="export JAVA_HOME=$GRAALVM_17_HOME && export PATH=$GRAALVM_17_HOME/bin/:$PATH"
export JAVA_HOME
export PATH=$JAVA_HOME/bin/:$PATH
export CLASSPATH

3.验证

1
java -version

控制台输出

1
2
3
openjdk version "17.0.7" 2023-04-18
OpenJDK Runtime Environment GraalVM CE 17.0.7+7.1 (build 17.0.7+7-jvmci-23.0-b12)
OpenJDK 64-Bit Server VM GraalVM CE 17.0.7+7.1 (build 17.0.7+7-jvmci-23.0-b12, mixed mode, sharing)
  1. 目前最新的GraalVM-CE版已经默认集成里native-image工具
    可以用
    1
    sudo gu install native-image
    验证或者安装
    1
    2
    3
    Downloading: Component catalog from www.graalvm.org
    Processing Component: Native Image
    Component Native Image (org.graalvm.native-image) is already installed.

搭建springboot3 工程

1.pom.xml 添加springboot3 web 依赖

AOT构建设置是在 build 标签里

1
2
3
4
5
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<version>0.9.21</version>
</plugin>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.cn.demo</groupId>
<artifactId>aot-demo</artifactId>
<version>1.0-SNAPSHOT</version>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.1.1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.plugin.validation>VERBOSE</maven.plugin.validation>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>



<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>


<build>
<plugins>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<version>0.9.21</version>

</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

</project>

工程代码

  1. Main
1
2
3
4
5
6
7
8
9
10
11
12
13
package com.cn.demo;


import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class AOTDemoApplication {
public static void main(String[] args) {
SpringApplication.run(AOTDemoApplication.class,args);
}
}

  1. controller
1
2
3
4
5
6
7
8
9
10
11
12
13
14
package com.cn.demo.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class DemoController {

@GetMapping("hello")
public Object hello(String name){
return String.format("Hello, %s ! From Spring AOT Demo.",name);
}
}

  1. 配置文件
    1
    2
    server.port=8081
    server.servlet.context-path=/promise

native-image 编译

1
mvn clean native:compile -Pnative

编译全过程输出

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
/bin/zsh /Users/promisechan/Desktop/code/java_code/springboot3-aot/aot-demo/build-native.sh
promisechan@PromiseChandeMacBook-Air aot-demo % /bin/zsh /Users/promisechan/Desktop/code/java_code/springboot3-aot/aot-demo/build-native.sh
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------< com.cn.demo:aot-demo >------------------------
[INFO] Building aot-demo 1.0-SNAPSHOT
[INFO] from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- clean:3.2.0:clean (default-clean) @ aot-demo ---
[INFO] Deleting /Users/promisechan/Desktop/code/java_code/springboot3-aot/aot-demo/target
[INFO]
[INFO] >>> native:0.9.21:compile (default-cli) > package @ aot-demo >>>
[INFO]
[INFO] --- native:0.9.21:add-reachability-metadata (add-reachability-metadata) @ aot-demo ---
[INFO] Downloaded GraalVM reachability metadata repository from file:/Users/promisechan/.m2/repository/org/graalvm/buildtools/graalvm-reachability-metadata/0.9.21/graalvm-reachability-metadata-0.9.21-repository.zip
[INFO] [graalvm reachability metadata repository for ch.qos.logback:logback-classic:1.4.8]: Configuration directory not found. Trying latest version.
[INFO] [graalvm reachability metadata repository for ch.qos.logback:logback-classic:1.4.8]: Configuration directory is ch.qos.logback/logback-classic/1.4.1
[INFO] [graalvm reachability metadata repository for org.apache.tomcat.embed:tomcat-embed-core:10.1.10]: Configuration directory not found. Trying latest version.
[INFO] [graalvm reachability metadata repository for org.apache.tomcat.embed:tomcat-embed-core:10.1.10]: Configuration directory is org.apache.tomcat.embed/tomcat-embed-core/10.0.20
[INFO] [graalvm reachability metadata repository for org.hdrhistogram:HdrHistogram:2.1.12]: Configuration directory is org.hdrhistogram/HdrHistogram/2.1.12
[INFO]
[INFO] --- resources:3.3.1:resources (default-resources) @ aot-demo ---
[INFO] Copying 1 resource from src/main/resources to target/classes
[INFO] Copying 0 resource from src/main/resources to target/classes
[INFO]
[INFO] --- compiler:3.11.0:compile (default-compile) @ aot-demo ---
[INFO] Changes detected - recompiling the module! :source
[INFO] Compiling 2 source files with javac [debug release 17] to target/classes
[INFO]
[INFO] --- resources:3.3.1:testResources (default-testResources) @ aot-demo ---
[INFO] skip non existing resourceDirectory /Users/promisechan/Desktop/code/java_code/springboot3-aot/aot-demo/src/test/resources
[INFO]
[INFO] --- compiler:3.11.0:testCompile (default-testCompile) @ aot-demo ---
[INFO] Changes detected - recompiling the module! :dependency
[INFO]
[INFO] --- surefire:3.0.0:test (default-test) @ aot-demo ---
[INFO]
[INFO] --- spring-boot:3.1.1:process-aot (process-aot) @ aot-demo ---

. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v3.1.1)

2023-07-13T23:34:14.744+08:00 INFO 3090 --- [ main] com.cn.demo.AOTDemoApplication : Starting AOTDemoApplication using Java 17.0.7 with PID 3090 (/Users/promisechan/Desktop/code/java_code/springboot3-aot/aot-demo/target/classes started by promisechan in /Users/promisechan/Desktop/code/java_code/springboot3-aot/aot-demo)
2023-07-13T23:34:14.746+08:00 INFO 3090 --- [ main] com.cn.demo.AOTDemoApplication : No active profile set, falling back to 1 default profile: "default"
[INFO]
[INFO] --- jar:3.3.0:jar (default-jar) @ aot-demo ---
[INFO] Building jar: /Users/promisechan/Desktop/code/java_code/springboot3-aot/aot-demo/target/aot-demo-1.0-SNAPSHOT.jar
[INFO]
[INFO] --- spring-boot:3.1.1:repackage (repackage) @ aot-demo ---
[INFO] Replacing main artifact /Users/promisechan/Desktop/code/java_code/springboot3-aot/aot-demo/target/aot-demo-1.0-SNAPSHOT.jar with repackaged archive, adding nested dependencies in BOOT-INF/.
[INFO] The original artifact has been renamed to /Users/promisechan/Desktop/code/java_code/springboot3-aot/aot-demo/target/aot-demo-1.0-SNAPSHOT.jar.original
[INFO]
[INFO] <<< native:0.9.21:compile (default-cli) < package @ aot-demo <<<
[INFO]
[INFO]
[INFO] --- native:0.9.21:compile (default-cli) @ aot-demo ---
[INFO] Found GraalVM installation from JAVA_HOME variable.
[INFO] [graalvm reachability metadata repository for org.apache.tomcat.embed:tomcat-embed-core:10.1.10]: Configuration directory not found. Trying latest version.
[INFO] [graalvm reachability metadata repository for org.apache.tomcat.embed:tomcat-embed-core:10.1.10]: Configuration directory is org.apache.tomcat.embed/tomcat-embed-core/10.0.20
[INFO] [graalvm reachability metadata repository for ch.qos.logback:logback-classic:1.4.8]: Configuration directory not found. Trying latest version.
[INFO] [graalvm reachability metadata repository for ch.qos.logback:logback-classic:1.4.8]: Configuration directory is ch.qos.logback/logback-classic/1.4.1
[INFO] [graalvm reachability metadata repository for org.hdrhistogram:HdrHistogram:2.1.12]: Configuration directory is org.hdrhistogram/HdrHistogram/2.1.12
[INFO] Executing: /Library/Java/JavaVirtualMachines/graalvm-community-openjdk-17.0.7+7.1/Contents/Home/bin/native-image -cp /Users/promisechan/Desktop/code/java_code/springboot3-aot/aot-demo/target/classes:/Users/promisechan/.m2/repository/org/apache/tomcat/embed/tomcat-embed-el/10.1.10/tomcat-embed-el-10.1.10.jar:/Users/promisechan/.m2/repository/org/slf4j/slf4j-api/2.0.7/slf4j-api-2.0.7.jar:/Users/promisechan/.m2/repository/com/fasterxml/jackson/module/jackson-module-parameter-names/2.15.2/jackson-module-parameter-names-2.15.2.jar:/Users/promisechan/.m2/repository/org/springframework/boot/spring-boot-starter-tomcat/3.1.1/spring-boot-starter-tomcat-3.1.1.jar:/Users/promisechan/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/10.1.10/tomcat-embed-core-10.1.10.jar:/Users/promisechan/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-jdk8/2.15.2/jackson-datatype-jdk8-2.15.2.jar:/Users/promisechan/.m2/repository/org/apache/logging/log4j/log4j-to-slf4j/2.20.0/log4j-to-slf4j-2.20.0.jar:/Users/promisechan/.m2/repository/org/springframework/spring-core/6.0.10/spring-core-6.0.10.jar:/Users/promisechan/.m2/repository/jakarta/annotation/jakarta.annotation-api/2.1.1/jakarta.annotation-api-2.1.1.jar:/Users/promisechan/.m2/repository/org/springframework/spring-webmvc/6.0.10/spring-webmvc-6.0.10.jar:/Users/promisechan/.m2/repository/org/springframework/spring-context/6.0.10/spring-context-6.0.10.jar:/Users/promisechan/.m2/repository/org/springframework/spring-expression/6.0.10/spring-expression-6.0.10.jar:/Users/promisechan/.m2/repository/org/springframework/boot/spring-boot-starter-actuator/3.1.1/spring-boot-starter-actuator-3.1.1.jar:/Users/promisechan/.m2/repository/org/springframework/boot/spring-boot-actuator/3.1.1/spring-boot-actuator-3.1.1.jar:/Users/promisechan/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.15.2/jackson-annotations-2.15.2.jar:/Users/promisechan/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.15.2/jackson-core-2.15.2.jar:/Users/promisechan/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/3.1.1/spring-boot-autoconfigure-3.1.1.jar:/Users/promisechan/.m2/repository/org/springframework/boot/spring-boot-starter-web/3.1.1/spring-boot-starter-web-3.1.1.jar:/Users/promisechan/.m2/repository/org/slf4j/jul-to-slf4j/2.0.7/jul-to-slf4j-2.0.7.jar:/Users/promisechan/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-jsr310/2.15.2/jackson-datatype-jsr310-2.15.2.jar:/Users/promisechan/.m2/repository/org/springframework/spring-aop/6.0.10/spring-aop-6.0.10.jar:/Users/promisechan/.m2/repository/ch/qos/logback/logback-core/1.4.8/logback-core-1.4.8.jar:/Users/promisechan/.m2/repository/org/springframework/boot/spring-boot-starter-json/3.1.1/spring-boot-starter-json-3.1.1.jar:/Users/promisechan/.m2/repository/org/springframework/boot/spring-boot-starter-logging/3.1.1/spring-boot-starter-logging-3.1.1.jar:/Users/promisechan/.m2/repository/ch/qos/logback/logback-classic/1.4.8/logback-classic-1.4.8.jar:/Users/promisechan/.m2/repository/io/micrometer/micrometer-core/1.11.1/micrometer-core-1.11.1.jar:/Users/promisechan/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.15.2/jackson-databind-2.15.2.jar:/Users/promisechan/.m2/repository/org/springframework/boot/spring-boot-actuator-autoconfigure/3.1.1/spring-boot-actuator-autoconfigure-3.1.1.jar:/Users/promisechan/.m2/repository/org/latencyutils/LatencyUtils/2.0.3/LatencyUtils-2.0.3.jar:/Users/promisechan/.m2/repository/org/apache/tomcat/embed/tomcat-embed-websocket/10.1.10/tomcat-embed-websocket-10.1.10.jar:/Users/promisechan/.m2/repository/org/hdrhistogram/HdrHistogram/2.1.12/HdrHistogram-2.1.12.jar:/Users/promisechan/.m2/repository/org/springframework/boot/spring-boot-starter/3.1.1/spring-boot-starter-3.1.1.jar:/Users/promisechan/.m2/repository/io/micrometer/micrometer-observation/1.11.1/micrometer-observation-1.11.1.jar:/Users/promisechan/.m2/repository/org/apache/logging/log4j/log4j-api/2.20.0/log4j-api-2.20.0.jar:/Users/promisechan/.m2/repository/org/yaml/snakeyaml/1.33/snakeyaml-1.33.jar:/Users/promisechan/.m2/repository/org/springframework/spring-beans/6.0.10/spring-beans-6.0.10.jar:/Users/promisechan/.m2/repository/org/springframework/boot/spring-boot/3.1.1/spring-boot-3.1.1.jar:/Users/promisechan/.m2/repository/org/springframework/spring-jcl/6.0.10/spring-jcl-6.0.10.jar:/Users/promisechan/.m2/repository/org/springframework/spring-web/6.0.10/spring-web-6.0.10.jar:/Users/promisechan/.m2/repository/io/micrometer/micrometer-commons/1.11.1/micrometer-commons-1.11.1.jar --no-fallback -H:Path=/Users/promisechan/Desktop/code/java_code/springboot3-aot/aot-demo/target -H:Name=aot-demo -H:ConfigurationFileDirectories=/Users/promisechan/Desktop/code/java_code/springboot3-aot/aot-demo/target/graalvm-reachability-metadata/960cff9d387a088993cb5d0b82fa45093d5a9650/org.hdrhistogram/HdrHistogram/2.1.12,/Users/promisechan/Desktop/code/java_code/springboot3-aot/aot-demo/target/graalvm-reachability-metadata/960cff9d387a088993cb5d0b82fa45093d5a9650/org.apache.tomcat.embed/tomcat-embed-core/10.0.20,/Users/promisechan/Desktop/code/java_code/springboot3-aot/aot-demo/target/graalvm-reachability-metadata/960cff9d387a088993cb5d0b82fa45093d5a9650/ch.qos.logback/logback-classic/1.4.1
=================================================================================================
GraalVM Native Image: Generating 'aot-demo' (executable)...
=================================================================================================
[1/8] Initializing... (6.2s @ 0.17GB)
Java version: 17.0.7+7, vendor version: GraalVM CE 17.0.7+7.1
Graal compiler: optimization level: 2, target machine: armv8-a
C compiler: cc (apple, arm64, 14.0.3)
Garbage collector: Serial GC (max heap size: 80% of RAM)
1 user-specific feature(s)
- org.springframework.aot.nativex.feature.PreComputeFieldFeature
Field org.apache.commons.logging.LogAdapter#log4jSpiPresent set to true at build time
Field org.apache.commons.logging.LogAdapter#log4jSlf4jProviderPresent set to true at build time
Field org.apache.commons.logging.LogAdapter#slf4jSpiPresent set to true at build time
Field org.apache.commons.logging.LogAdapter#slf4jApiPresent set to true at build time
Field org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#romePresent set to false at build time
Field org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#jaxb2Present set to false at build time
Field org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#jackson2Present set to true at build time
Field org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#jackson2XmlPresent set to false at build time
Field org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#jackson2SmilePresent set to false at build time
Field org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#jackson2CborPresent set to false at build time
Field org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#gsonPresent set to false at build time
Field org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#jsonbPresent set to false at build time
Field org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#kotlinSerializationCborPresent set to false at build time
Field org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#kotlinSerializationJsonPresent set to false at build time
Field org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#kotlinSerializationProtobufPresent set to false at build time
Field org.springframework.http.converter.json.Jackson2ObjectMapperBuilder#jackson2XmlPresent set to false at build time
Field org.springframework.boot.logging.log4j2.Log4J2LoggingSystem$Factory#PRESENT set to false at build time
Field org.springframework.boot.logging.logback.LogbackLoggingSystem$Factory#PRESENT set to true at build time
Field org.springframework.web.servlet.view.InternalResourceViewResolver#jstlPresent set to false at build time
Field org.springframework.web.client.RestTemplate#romePresent set to false at build time
Field org.springframework.web.client.RestTemplate#jaxb2Present set to false at build time
Field org.springframework.web.client.RestTemplate#jackson2Present set to true at build time
Field org.springframework.web.client.RestTemplate#jackson2XmlPresent set to false at build time
Field org.springframework.web.client.RestTemplate#jackson2SmilePresent set to false at build time
Field org.springframework.web.client.RestTemplate#jackson2CborPresent set to false at build time
Field org.springframework.web.client.RestTemplate#gsonPresent set to false at build time
Field org.springframework.web.client.RestTemplate#jsonbPresent set to false at build time
Field org.springframework.web.client.RestTemplate#kotlinSerializationCborPresent set to false at build time
Field org.springframework.web.client.RestTemplate#kotlinSerializationJsonPresent set to false at build time
Field org.springframework.web.client.RestTemplate#kotlinSerializationProtobufPresent set to false at build time
Field org.springframework.core.NativeDetector#inNativeImage set to true at build time
Field org.springframework.cglib.core.AbstractClassGenerator#inNativeImage set to true at build time
Field org.springframework.core.KotlinDetector#kotlinPresent set to false at build time
Field org.springframework.core.KotlinDetector#kotlinReflectPresent set to false at build time
Field org.springframework.aot.AotDetector#inNativeImage set to true at build time
Field org.springframework.boot.logging.java.JavaLoggingSystem$Factory#PRESENT set to true at build time
Field org.springframework.format.support.DefaultFormattingConversionService#jsr354Present set to false at build time
Field org.springframework.web.context.support.StandardServletEnvironment#jndiPresent set to true at build time
Field org.springframework.boot.logging.logback.LogbackLoggingSystemProperties#JBOSS_LOGGING_PRESENT set to false at build time
Field org.springframework.web.context.support.WebApplicationContextUtils#jsfPresent set to false at build time
Field org.springframework.web.context.request.RequestContextHolder#jsfPresent set to false at build time
Field org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter#jaxb2Present set to false at build time
Field org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter#jackson2Present set to true at build time
Field org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter#jackson2XmlPresent set to false at build time
Field org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter#jackson2SmilePresent set to false at build time
Field org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter#gsonPresent set to false at build time
Field org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter#jsonbPresent set to false at build time
Field org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter#kotlinSerializationCborPresent set to false at build time
Field org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter#kotlinSerializationJsonPresent set to false at build time
Field org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter#kotlinSerializationProtobufPresent set to false at build time
Field org.springframework.boot.actuate.endpoint.invoke.reflect.OperationMethodParameter#jsr305Present set to false at build time
Field org.springframework.context.event.ApplicationListenerMethodAdapter#reactiveStreamsPresent set to false at build time
Field org.springframework.core.ReactiveAdapterRegistry#reactorPresent set to false at build time
Field org.springframework.core.ReactiveAdapterRegistry#rxjava3Present set to false at build time
Field org.springframework.core.ReactiveAdapterRegistry#kotlinCoroutinesPresent set to false at build time
Field org.springframework.core.ReactiveAdapterRegistry#mutinyPresent set to false at build time
Field org.springframework.boot.actuate.endpoint.web.annotation.DiscoveredWebOperation#REACTIVE_STREAMS_PRESENT set to false at build time
SLF4J: No SLF4J providers were found.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See https://www.slf4j.org/codes.html#noProviders for further details.
Field org.springframework.web.servlet.mvc.method.annotation.ReactiveTypeHandler#isContextPropagationPresent set to false at build time
Field org.springframework.boot.autoconfigure.web.format.WebConversionService#JSR_354_PRESENT set to false at build time
Field org.springframework.boot.actuate.endpoint.invoker.cache.CachingOperationInvoker#IS_REACTOR_PRESENT set to false at build time
Field org.springframework.web.servlet.support.RequestContext#jstlPresent set to false at build time
[2/8] Performing analysis... [******] (29.0s @ 1.36GB)
16,351 (90.92%) of 17,983 types reachable
26,226 (67.84%) of 38,661 fields reachable
77,648 (63.62%) of 122,054 methods reachable
5,112 types, 282 fields, and 5,649 methods registered for reflection
64 types, 71 fields, and 55 methods registered for JNI access
5 native libraries: -framework CoreServices, -framework Foundation, dl, pthread, z
[3/8] Building universe... (3.6s @ 1.54GB)
[4/8] Parsing methods... [**] (3.5s @ 0.94GB)
[5/8] Inlining methods... [***] (1.5s @ 1.03GB)
[6/8] Compiling methods... [*****] (22.6s @ 1.60GB)
[7/8] Layouting methods... [***] (5.8s @ 1.32GB)
[8/8] Creating image... [***] (7.2s @ 1.76GB)
35.95MB (51.39%) for code area: 50,579 compilation units
33.09MB (47.32%) for image heap: 385,800 objects and 115 resources
922.88kB ( 1.29%) for other data
69.94MB in total
-------------------------------------------------------------------------------------------------
Top 10 origins of code area: Top 10 object types in image heap:
12.63MB java.base 8.29MB byte[] for code metadata
4.16MB tomcat-embed-core-10.1.10.jar 3.88MB java.lang.Class
2.64MB java.xml 3.69MB java.lang.String
1.93MB jackson-databind-2.15.2.jar 3.26MB byte[] for java.lang.String
1.50MB spring-core-6.0.10.jar 3.00MB byte[] for general heap data
1.30MB svm.jar (Native Image) 1.37MB c.o.svm.core.hub.DynamicHubCompanion
1.26MB spring-boot-3.1.1.jar 1000.23kB byte[] for reflection metadata
906.01kB spring-web-6.0.10.jar 777.81kB byte[] for embedded resources
860.63kB spring-beans-6.0.10.jar 723.46kB java.lang.String[]
828.91kB spring-webmvc-6.0.10.jar 655.08kB java.util.HashMap$Node
7.70MB for 92 more packages 5.97MB for 3423 more object types
-------------------------------------------------------------------------------------------------
Recommendations:
HEAP: Set max heap for improved and more predictable memory usage.
CPU: Enable more CPU features with '-march=native' for improved performance.
-------------------------------------------------------------------------------------------------
11.3s (13.9% of total time) in 205 GCs | Peak RSS: 2.37GB | CPU load: 5.70
-------------------------------------------------------------------------------------------------
Produced artifacts:
/Users/promisechan/Desktop/code/java_code/springboot3-aot/aot-demo/target/aot-demo (executable)
=================================================================================================
Finished generating 'aot-demo' in 1m 20s.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:25 min
[INFO] Finished at: 2023-07-13T23:35:37+08:00
[INFO] ------------------------------------------------------------------------
[WARNING]
[WARNING] Plugin validation issues were detected in 1 plugin(s)
[WARNING]
[WARNING] * org.apache.maven.plugins:maven-surefire-plugin:3.0.0
[WARNING]
[WARNING] For more or less details, use 'maven.plugin.validation' property with one of the values (case insensitive): [BRIEF, DEFAULT, VERBOSE]
[WARNING]
promisechan@PromiseChandeMacBook-Air aot-demo % clear
promisechan@PromiseChandeMacBook-Air aot-demo % ./target/aot-demo

. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v3.1.1)

2023-07-13T23:36:03.231+08:00 INFO 3179 --- [ main] com.cn.demo.AOTDemoApplication : Starting AOT-processed AOTDemoApplication using Java 17.0.7 with PID 3179 (/Users/promisechan/Desktop/code/java_code/springboot3-aot/aot-demo/target/aot-demo started by promisechan in /Users/promisechan/Desktop/code/java_code/springboot3-aot/aot-demo)
2023-07-13T23:36:03.231+08:00 INFO 3179 --- [ main] com.cn.demo.AOTDemoApplication : No active profile set, falling back to 1 default profile: "default"
2023-07-13T23:36:03.250+08:00 INFO 3179 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8081 (http)
2023-07-13T23:36:03.251+08:00 INFO 3179 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2023-07-13T23:36:03.251+08:00 INFO 3179 --- [ main] o.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/10.1.10]
2023-07-13T23:36:03.257+08:00 INFO 3179 --- [ main] o.a.c.c.C.[.[localhost].[/promise] : Initializing Spring embedded WebApplicationContext
2023-07-13T23:36:03.258+08:00 INFO 3179 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 26 ms
2023-07-13T23:36:03.281+08:00 INFO 3179 --- [ main] o.s.b.a.e.web.EndpointLinksResolver : Exposing 1 endpoint(s) beneath base path '/actuator'
2023-07-13T23:36:03.294+08:00 INFO 3179 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8081 (http) with context path '/promise'
2023-07-13T23:36:03.294+08:00 INFO 3179 --- [ main] com.cn.demo.AOTDemoApplication : Started AOTDemoApplication in 0.084 seconds (process running for 0.107)
^C% promisechan@PromiseChandeMacBook-Air aot-demo % clear
promisechan@PromiseChandeMacBook-Air aot-demo % /bin/zsh /Users/promisechan/Desktop/code/java_code/springboot3-aot/aot-demo/build-native.sh
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------< com.cn.demo:aot-demo >------------------------
[INFO] Building aot-demo 1.0-SNAPSHOT
[INFO] from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- clean:3.2.0:clean (default-clean) @ aot-demo ---
[INFO] Deleting /Users/promisechan/Desktop/code/java_code/springboot3-aot/aot-demo/target
[INFO]
[INFO] >>> native:0.9.21:compile (default-cli) > package @ aot-demo >>>
[INFO]
[INFO] --- native:0.9.21:add-reachability-metadata (add-reachability-metadata) @ aot-demo ---
[INFO] Downloaded GraalVM reachability metadata repository from file:/Users/promisechan/.m2/repository/org/graalvm/buildtools/graalvm-reachability-metadata/0.9.21/graalvm-reachability-metadata-0.9.21-repository.zip
[INFO] [graalvm reachability metadata repository for ch.qos.logback:logback-classic:1.4.8]: Configuration directory not found. Trying latest version.
[INFO] [graalvm reachability metadata repository for ch.qos.logback:logback-classic:1.4.8]: Configuration directory is ch.qos.logback/logback-classic/1.4.1
[INFO] [graalvm reachability metadata repository for org.apache.tomcat.embed:tomcat-embed-core:10.1.10]: Configuration directory not found. Trying latest version.
[INFO] [graalvm reachability metadata repository for org.apache.tomcat.embed:tomcat-embed-core:10.1.10]: Configuration directory is org.apache.tomcat.embed/tomcat-embed-core/10.0.20
[INFO] [graalvm reachability metadata repository for org.hdrhistogram:HdrHistogram:2.1.12]: Configuration directory is org.hdrhistogram/HdrHistogram/2.1.12
[INFO]
[INFO] --- resources:3.3.1:resources (default-resources) @ aot-demo ---
[INFO] Copying 1 resource from src/main/resources to target/classes
[INFO] Copying 0 resource from src/main/resources to target/classes
[INFO]
[INFO] --- compiler:3.11.0:compile (default-compile) @ aot-demo ---
[INFO] Changes detected - recompiling the module! :source
[INFO] Compiling 2 source files with javac [debug release 17] to target/classes
[INFO]
[INFO] --- resources:3.3.1:testResources (default-testResources) @ aot-demo ---
[INFO] skip non existing resourceDirectory /Users/promisechan/Desktop/code/java_code/springboot3-aot/aot-demo/src/test/resources
[INFO]
[INFO] --- compiler:3.11.0:testCompile (default-testCompile) @ aot-demo ---
[INFO] Changes detected - recompiling the module! :dependency
[INFO]
[INFO] --- surefire:3.0.0:test (default-test) @ aot-demo ---
[INFO]
[INFO] --- spring-boot:3.1.1:process-aot (process-aot) @ aot-demo ---

. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v3.1.1)

2023-07-14T00:01:45.900+08:00 INFO 3613 --- [ main] com.cn.demo.AOTDemoApplication : Starting AOTDemoApplication using Java 17.0.7 with PID 3613 (/Users/promisechan/Desktop/code/java_code/springboot3-aot/aot-demo/target/classes started by promisechan in /Users/promisechan/Desktop/code/java_code/springboot3-aot/aot-demo)
2023-07-14T00:01:45.901+08:00 INFO 3613 --- [ main] com.cn.demo.AOTDemoApplication : No active profile set, falling back to 1 default profile: "default"
[INFO]
[INFO] --- jar:3.3.0:jar (default-jar) @ aot-demo ---
[INFO] Building jar: /Users/promisechan/Desktop/code/java_code/springboot3-aot/aot-demo/target/aot-demo-1.0-SNAPSHOT.jar
[INFO]
[INFO] --- spring-boot:3.1.1:repackage (repackage) @ aot-demo ---
[INFO] Replacing main artifact /Users/promisechan/Desktop/code/java_code/springboot3-aot/aot-demo/target/aot-demo-1.0-SNAPSHOT.jar with repackaged archive, adding nested dependencies in BOOT-INF/.
[INFO] The original artifact has been renamed to /Users/promisechan/Desktop/code/java_code/springboot3-aot/aot-demo/target/aot-demo-1.0-SNAPSHOT.jar.original
[INFO]
[INFO] <<< native:0.9.21:compile (default-cli) < package @ aot-demo <<<
[INFO]
[INFO]
[INFO] --- native:0.9.21:compile (default-cli) @ aot-demo ---
[INFO] Found GraalVM installation from JAVA_HOME variable.
[INFO] [graalvm reachability metadata repository for org.apache.tomcat.embed:tomcat-embed-core:10.1.10]: Configuration directory not found. Trying latest version.
[INFO] [graalvm reachability metadata repository for org.apache.tomcat.embed:tomcat-embed-core:10.1.10]: Configuration directory is org.apache.tomcat.embed/tomcat-embed-core/10.0.20
[INFO] [graalvm reachability metadata repository for ch.qos.logback:logback-classic:1.4.8]: Configuration directory not found. Trying latest version.
[INFO] [graalvm reachability metadata repository for ch.qos.logback:logback-classic:1.4.8]: Configuration directory is ch.qos.logback/logback-classic/1.4.1
[INFO] [graalvm reachability metadata repository for org.hdrhistogram:HdrHistogram:2.1.12]: Configuration directory is org.hdrhistogram/HdrHistogram/2.1.12
[INFO] Executing: /Library/Java/JavaVirtualMachines/graalvm-community-openjdk-17.0.7+7.1/Contents/Home/bin/native-image -cp /Users/promisechan/Desktop/code/java_code/springboot3-aot/aot-demo/target/classes:/Users/promisechan/.m2/repository/org/apache/tomcat/embed/tomcat-embed-el/10.1.10/tomcat-embed-el-10.1.10.jar:/Users/promisechan/.m2/repository/org/slf4j/slf4j-api/2.0.7/slf4j-api-2.0.7.jar:/Users/promisechan/.m2/repository/com/fasterxml/jackson/module/jackson-module-parameter-names/2.15.2/jackson-module-parameter-names-2.15.2.jar:/Users/promisechan/.m2/repository/org/springframework/boot/spring-boot-starter-tomcat/3.1.1/spring-boot-starter-tomcat-3.1.1.jar:/Users/promisechan/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/10.1.10/tomcat-embed-core-10.1.10.jar:/Users/promisechan/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-jdk8/2.15.2/jackson-datatype-jdk8-2.15.2.jar:/Users/promisechan/.m2/repository/org/apache/logging/log4j/log4j-to-slf4j/2.20.0/log4j-to-slf4j-2.20.0.jar:/Users/promisechan/.m2/repository/org/springframework/spring-core/6.0.10/spring-core-6.0.10.jar:/Users/promisechan/.m2/repository/jakarta/annotation/jakarta.annotation-api/2.1.1/jakarta.annotation-api-2.1.1.jar:/Users/promisechan/.m2/repository/org/springframework/spring-webmvc/6.0.10/spring-webmvc-6.0.10.jar:/Users/promisechan/.m2/repository/org/springframework/spring-context/6.0.10/spring-context-6.0.10.jar:/Users/promisechan/.m2/repository/org/springframework/spring-expression/6.0.10/spring-expression-6.0.10.jar:/Users/promisechan/.m2/repository/org/springframework/boot/spring-boot-starter-actuator/3.1.1/spring-boot-starter-actuator-3.1.1.jar:/Users/promisechan/.m2/repository/org/springframework/boot/spring-boot-actuator/3.1.1/spring-boot-actuator-3.1.1.jar:/Users/promisechan/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.15.2/jackson-annotations-2.15.2.jar:/Users/promisechan/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.15.2/jackson-core-2.15.2.jar:/Users/promisechan/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/3.1.1/spring-boot-autoconfigure-3.1.1.jar:/Users/promisechan/.m2/repository/org/springframework/boot/spring-boot-starter-web/3.1.1/spring-boot-starter-web-3.1.1.jar:/Users/promisechan/.m2/repository/org/slf4j/jul-to-slf4j/2.0.7/jul-to-slf4j-2.0.7.jar:/Users/promisechan/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-jsr310/2.15.2/jackson-datatype-jsr310-2.15.2.jar:/Users/promisechan/.m2/repository/org/springframework/spring-aop/6.0.10/spring-aop-6.0.10.jar:/Users/promisechan/.m2/repository/ch/qos/logback/logback-core/1.4.8/logback-core-1.4.8.jar:/Users/promisechan/.m2/repository/org/springframework/boot/spring-boot-starter-json/3.1.1/spring-boot-starter-json-3.1.1.jar:/Users/promisechan/.m2/repository/org/springframework/boot/spring-boot-starter-logging/3.1.1/spring-boot-starter-logging-3.1.1.jar:/Users/promisechan/.m2/repository/ch/qos/logback/logback-classic/1.4.8/logback-classic-1.4.8.jar:/Users/promisechan/.m2/repository/io/micrometer/micrometer-core/1.11.1/micrometer-core-1.11.1.jar:/Users/promisechan/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.15.2/jackson-databind-2.15.2.jar:/Users/promisechan/.m2/repository/org/springframework/boot/spring-boot-actuator-autoconfigure/3.1.1/spring-boot-actuator-autoconfigure-3.1.1.jar:/Users/promisechan/.m2/repository/org/latencyutils/LatencyUtils/2.0.3/LatencyUtils-2.0.3.jar:/Users/promisechan/.m2/repository/org/apache/tomcat/embed/tomcat-embed-websocket/10.1.10/tomcat-embed-websocket-10.1.10.jar:/Users/promisechan/.m2/repository/org/hdrhistogram/HdrHistogram/2.1.12/HdrHistogram-2.1.12.jar:/Users/promisechan/.m2/repository/org/springframework/boot/spring-boot-starter/3.1.1/spring-boot-starter-3.1.1.jar:/Users/promisechan/.m2/repository/io/micrometer/micrometer-observation/1.11.1/micrometer-observation-1.11.1.jar:/Users/promisechan/.m2/repository/org/apache/logging/log4j/log4j-api/2.20.0/log4j-api-2.20.0.jar:/Users/promisechan/.m2/repository/org/yaml/snakeyaml/1.33/snakeyaml-1.33.jar:/Users/promisechan/.m2/repository/org/springframework/spring-beans/6.0.10/spring-beans-6.0.10.jar:/Users/promisechan/.m2/repository/org/springframework/boot/spring-boot/3.1.1/spring-boot-3.1.1.jar:/Users/promisechan/.m2/repository/org/springframework/spring-jcl/6.0.10/spring-jcl-6.0.10.jar:/Users/promisechan/.m2/repository/org/springframework/spring-web/6.0.10/spring-web-6.0.10.jar:/Users/promisechan/.m2/repository/io/micrometer/micrometer-commons/1.11.1/micrometer-commons-1.11.1.jar --no-fallback -H:Path=/Users/promisechan/Desktop/code/java_code/springboot3-aot/aot-demo/target -H:Name=aot-demo -H:ConfigurationFileDirectories=/Users/promisechan/Desktop/code/java_code/springboot3-aot/aot-demo/target/graalvm-reachability-metadata/960cff9d387a088993cb5d0b82fa45093d5a9650/org.hdrhistogram/HdrHistogram/2.1.12,/Users/promisechan/Desktop/code/java_code/springboot3-aot/aot-demo/target/graalvm-reachability-metadata/960cff9d387a088993cb5d0b82fa45093d5a9650/ch.qos.logback/logback-classic/1.4.1,/Users/promisechan/Desktop/code/java_code/springboot3-aot/aot-demo/target/graalvm-reachability-metadata/960cff9d387a088993cb5d0b82fa45093d5a9650/org.apache.tomcat.embed/tomcat-embed-core/10.0.20
=================================================================================================
GraalVM Native Image: Generating 'aot-demo' (executable)...
=================================================================================================
[1/8] Initializing... (7.8s @ 0.15GB)
Java version: 17.0.7+7, vendor version: GraalVM CE 17.0.7+7.1
Graal compiler: optimization level: 2, target machine: armv8-a
C compiler: cc (apple, arm64, 14.0.3)
Garbage collector: Serial GC (max heap size: 80% of RAM)
1 user-specific feature(s)
- org.springframework.aot.nativex.feature.PreComputeFieldFeature
Field org.apache.commons.logging.LogAdapter#log4jSpiPresent set to true at build time
Field org.apache.commons.logging.LogAdapter#log4jSlf4jProviderPresent set to true at build time
Field org.apache.commons.logging.LogAdapter#slf4jSpiPresent set to true at build time
Field org.apache.commons.logging.LogAdapter#slf4jApiPresent set to true at build time
Field org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#romePresent set to false at build time
Field org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#jaxb2Present set to false at build time
Field org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#jackson2Present set to true at build time
Field org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#jackson2XmlPresent set to false at build time
Field org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#jackson2SmilePresent set to false at build time
Field org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#jackson2CborPresent set to false at build time
Field org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#gsonPresent set to false at build time
Field org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#jsonbPresent set to false at build time
Field org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#kotlinSerializationCborPresent set to false at build time
Field org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#kotlinSerializationJsonPresent set to false at build time
Field org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport#kotlinSerializationProtobufPresent set to false at build time
Field org.springframework.core.NativeDetector#inNativeImage set to true at build time
Field org.springframework.boot.logging.log4j2.Log4J2LoggingSystem$Factory#PRESENT set to false at build time
Field org.springframework.http.converter.json.Jackson2ObjectMapperBuilder#jackson2XmlPresent set to false at build time
Field org.springframework.web.servlet.view.InternalResourceViewResolver#jstlPresent set to false at build time
Field org.springframework.cglib.core.AbstractClassGenerator#inNativeImage set to true at build time
Field org.springframework.web.client.RestTemplate#romePresent set to false at build time
Field org.springframework.web.client.RestTemplate#jaxb2Present set to false at build time
Field org.springframework.web.client.RestTemplate#jackson2Present set to true at build time
Field org.springframework.web.client.RestTemplate#jackson2XmlPresent set to false at build time
Field org.springframework.web.client.RestTemplate#jackson2SmilePresent set to false at build time
Field org.springframework.web.client.RestTemplate#jackson2CborPresent set to false at build time
Field org.springframework.web.client.RestTemplate#gsonPresent set to false at build time
Field org.springframework.web.client.RestTemplate#jsonbPresent set to false at build time
Field org.springframework.web.client.RestTemplate#kotlinSerializationCborPresent set to false at build time
Field org.springframework.web.client.RestTemplate#kotlinSerializationJsonPresent set to false at build time
Field org.springframework.web.client.RestTemplate#kotlinSerializationProtobufPresent set to false at build time
Field org.springframework.boot.logging.java.JavaLoggingSystem$Factory#PRESENT set to true at build time
Field org.springframework.boot.logging.logback.LogbackLoggingSystem$Factory#PRESENT set to true at build time
Field org.springframework.aot.AotDetector#inNativeImage set to true at build time
Field org.springframework.core.KotlinDetector#kotlinPresent set to false at build time
Field org.springframework.core.KotlinDetector#kotlinReflectPresent set to false at build time
Field org.springframework.format.support.DefaultFormattingConversionService#jsr354Present set to false at build time
Field org.springframework.web.context.support.StandardServletEnvironment#jndiPresent set to true at build time
Field org.springframework.web.context.support.WebApplicationContextUtils#jsfPresent set to false at build time
Field org.springframework.web.context.request.RequestContextHolder#jsfPresent set to false at build time
Field org.springframework.context.event.ApplicationListenerMethodAdapter#reactiveStreamsPresent set to false at build time
Field org.springframework.boot.autoconfigure.web.format.WebConversionService#JSR_354_PRESENT set to false at build time
Field org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter#jaxb2Present set to false at build time
Field org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter#jackson2Present set to true at build time
Field org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter#jackson2XmlPresent set to false at build time
Field org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter#jackson2SmilePresent set to false at build time
Field org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter#gsonPresent set to false at build time
Field org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter#jsonbPresent set to false at build time
Field org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter#kotlinSerializationCborPresent set to false at build time
Field org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter#kotlinSerializationJsonPresent set to false at build time
Field org.springframework.http.converter.support.AllEncompassingFormHttpMessageConverter#kotlinSerializationProtobufPresent set to false at build time
Field org.springframework.boot.actuate.endpoint.invoke.reflect.OperationMethodParameter#jsr305Present set to false at build time
Field org.springframework.boot.actuate.endpoint.web.annotation.DiscoveredWebOperation#REACTIVE_STREAMS_PRESENT set to false at build time
Field org.springframework.core.ReactiveAdapterRegistry#reactorPresent set to false at build time
Field org.springframework.core.ReactiveAdapterRegistry#rxjava3Present set to false at build time
Field org.springframework.core.ReactiveAdapterRegistry#kotlinCoroutinesPresent set to false at build time
Field org.springframework.core.ReactiveAdapterRegistry#mutinyPresent set to false at build time
SLF4J: No SLF4J providers were found.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See https://www.slf4j.org/codes.html#noProviders for further details.
Field org.springframework.web.servlet.mvc.method.annotation.ReactiveTypeHandler#isContextPropagationPresent set to false at build time
Field org.springframework.boot.logging.logback.LogbackLoggingSystemProperties#JBOSS_LOGGING_PRESENT set to false at build time
Field org.springframework.boot.actuate.endpoint.invoker.cache.CachingOperationInvoker#IS_REACTOR_PRESENT set to false at build time
Field org.springframework.web.servlet.support.RequestContext#jstlPresent set to false at build time
[2/8] Performing analysis... [******] (33.1s @ 1.49GB)
16,351 (90.92%) of 17,983 types reachable
26,226 (67.84%) of 38,661 fields reachable
77,649 (63.61%) of 122,061 methods reachable
5,112 types, 282 fields, and 5,649 methods registered for reflection
64 types, 71 fields, and 55 methods registered for JNI access
5 native libraries: -framework CoreServices, -framework Foundation, dl, pthread, z
[3/8] Building universe... (9.7s @ 1.30GB)
[4/8] Parsing methods... [**] (3.4s @ 0.95GB)
[5/8] Inlining methods... [***] (1.4s @ 1.13GB)
[6/8] Compiling methods... [*****] (21.6s @ 1.49GB)
[7/8] Layouting methods... [***] (6.1s @ 1.42GB)
[8/8] Creating image... [***] (7.7s @ 1.29GB)
35.94MB (51.39%) for code area: 50,580 compilation units
33.09MB (47.32%) for image heap: 385,814 objects and 115 resources
923.54kB ( 1.29%) for other data
69.94MB in total
-------------------------------------------------------------------------------------------------
Top 10 origins of code area: Top 10 object types in image heap:
12.63MB java.base 8.29MB byte[] for code metadata
4.16MB tomcat-embed-core-10.1.10.jar 3.88MB java.lang.Class
2.64MB java.xml 3.69MB java.lang.String
1.93MB jackson-databind-2.15.2.jar 3.26MB byte[] for java.lang.String
1.50MB spring-core-6.0.10.jar 3.00MB byte[] for general heap data
1.30MB svm.jar (Native Image) 1.37MB c.o.svm.core.hub.DynamicHubCompanion
1.26MB spring-boot-3.1.1.jar 1000.23kB byte[] for reflection metadata
905.94kB spring-web-6.0.10.jar 777.81kB byte[] for embedded resources
860.50kB spring-beans-6.0.10.jar 723.45kB java.lang.String[]
828.80kB spring-webmvc-6.0.10.jar 656.39kB java.util.HashMap$Node
7.70MB for 92 more packages 5.96MB for 3423 more object types
-------------------------------------------------------------------------------------------------
Recommendations:
HEAP: Set max heap for improved and more predictable memory usage.
CPU: Enable more CPU features with '-march=native' for improved performance.
-------------------------------------------------------------------------------------------------
18.8s (20.5% of total time) in 263 GCs | Peak RSS: 2.04GB | CPU load: 5.24
-------------------------------------------------------------------------------------------------
Produced artifacts:
/Users/promisechan/Desktop/code/java_code/springboot3-aot/aot-demo/target/aot-demo (executable)
=================================================================================================
Finished generating 'aot-demo' in 1m 31s.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:35 min
[INFO] Finished at: 2023-07-14T00:03:20+08:00
[INFO] ------------------------------------------------------------------------
[WARNING]
[WARNING] Plugin validation issues were detected in 1 plugin(s)
[WARNING]
[WARNING] * org.apache.maven.plugins:maven-surefire-plugin:3.0.0
[WARNING]
[WARNING] For more or less details, use 'maven.plugin.validation' property with one of the values (case insensitive): [BRIEF, DEFAULT, VERBOSE]
[WARNING]

执行二进制文件

./target/aot-demo

控制台返回

1
Started AOTDemoApplication in 0.086 seconds (process running for 0.099)

验证

1
curl http://127.0.0.1:8081/promise/hello?name=cn

控制台返回

1
Hello, cn ! From Spring AOT Demo.