应用启动 (startup
)
startup
)
startup
端点提供了有关应用程序启动顺序的信息。
检索应用程序启动步骤
应用程序的启动步骤可以以快照的形式获取(GET
)或从缓冲区中排空(POST
)。
获取应用程序启动步骤的快照
要检索应用程序启动阶段记录的所有步骤,请向 /actuator/startup
发送一个 GET
请求,如下面基于 curl 的示例所示:
$ curl 'http://localhost:8080/actuator/startup' -i -X GET
生成的结果类似于以下内容:
HTTP/1.1 200 OK
Content-Type: application/vnd.spring-boot.actuator.v3+json
Content-Length: 889
{
"springBootVersion" : "3.4.2",
"timeline" : {
"startTime" : "2025-01-23T11:07:06.973866735Z",
"events" : [ {
"endTime" : "2025-01-23T11:07:07.387378607Z",
"duration" : "PT0.000006031S",
"startTime" : "2025-01-23T11:07:07.387372576Z",
"startupStep" : {
"name" : "spring.beans.instantiate",
"id" : 3,
"tags" : [ {
"key" : "beanName",
"value" : "homeController"
} ],
"parentId" : 2
}
}, {
"endTime" : "2025-01-23T11:07:07.387405146Z",
"duration" : "PT0.000041206S",
"startTime" : "2025-01-23T11:07:07.387363940Z",
"startupStep" : {
"name" : "spring.boot.application.starting",
"id" : 2,
"tags" : [ {
"key" : "mainApplicationClass",
"value" : "com.example.startup.StartupApplication"
} ]
}
} ]
}
}
排空应用程序启动步骤
要在应用程序启动阶段排出并返回到目前为止记录的步骤,请向 /actuator/startup
发起一个 POST
请求,如下面的基于 curl 的示例所示:
$ curl 'http://localhost:8080/actuator/startup' -i -X POST
生成的响应类似于以下内容:
HTTP/1.1 200 OK
Content-Type: application/vnd.spring-boot.actuator.v3+json
Content-Length: 889
{
"springBootVersion" : "3.4.2",
"timeline" : {
"startTime" : "2025-01-23T11:07:06.973866735Z",
"events" : [ {
"endTime" : "2025-01-23T11:07:07.323183455Z",
"duration" : "PT0.000207598S",
"startTime" : "2025-01-23T11:07:07.322975857Z",
"startupStep" : {
"name" : "spring.beans.instantiate",
"id" : 1,
"tags" : [ {
"key" : "beanName",
"value" : "homeController"
} ],
"parentId" : 0
}
}, {
"endTime" : "2025-01-23T11:07:07.323209353Z",
"duration" : "PT0.001117737S",
"startTime" : "2025-01-23T11:07:07.322091616Z",
"startupStep" : {
"name" : "spring.boot.application.starting",
"id" : 0,
"tags" : [ {
"key" : "mainApplicationClass",
"value" : "com.example.startup.StartupApplication"
} ]
}
} ]
}
}
响应结构
响应中包含了应用程序启动步骤的详细信息。下表描述了响应的结构:
路径 | 类型 | 描述 |
---|---|---|
springBootVersion | String | 该应用程序的 Spring Boot 版本。 |
timeline.startTime | String | 应用程序的启动时间。 |
timeline.events | Array | 到目前为止在应用程序启动期间收集的步骤数组。 |
timeline.events.[].startTime | String | 该事件的开始时间戳。 |
timeline.events.[].endTime | String | 该事件的结束时间戳。 |
timeline.events.[].duration | String | 该事件的精确持续时间。 |
timeline.events.[].startupStep.name | String | StartupStep 的名称。 |
timeline.events.[].startupStep.id | Number | 该 StartupStep 的 ID。 |
timeline.events.[].startupStep.parentId | Number | 该 StartupStep 的父级 ID。 |
timeline.events.[].startupStep.tags | Array | 包含额外步骤信息的键值对数组。 |
timeline.events.[].startupStep.tags[].key | String | StartupStep 标签的键。 |
timeline.events.[].startupStep.tags[].value | String | StartupStep 标签的值。 |