跳到主要内容

应用启动 (startup)

DeepSeek V3 中英对照 Application Startup (startup) Application Startup (startup)

startup 端点提供了有关应用程序启动顺序的信息。

检索应用程序启动步骤

应用程序的启动步骤可以以快照的形式获取(GET)或从缓冲区中排空(POST)。

获取应用程序启动步骤的快照

要检索应用程序启动阶段记录的所有步骤,请向 /actuator/startup 发送一个 GET 请求,如下面基于 curl 的示例所示:

$ curl 'http://localhost:8080/actuator/startup' -i -X GET
bash

生成的结果类似于以下内容:

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"
} ]
}
} ]
}
}
http

排空应用程序启动步骤

要在应用程序启动阶段排出并返回到目前为止记录的步骤,请向 /actuator/startup 发起一个 POST 请求,如下面的基于 curl 的示例所示:

$ curl 'http://localhost:8080/actuator/startup' -i -X POST
bash

生成的响应类似于以下内容:

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"
} ]
}
} ]
}
}
http

响应结构

响应中包含了应用程序启动步骤的详细信息。下表描述了响应的结构:

路径类型描述
springBootVersionString该应用程序的 Spring Boot 版本。
timeline.startTimeString应用程序的启动时间。
timeline.eventsArray到目前为止在应用程序启动期间收集的步骤数组。
timeline.events.[].startTimeString该事件的开始时间戳。
timeline.events.[].endTimeString该事件的结束时间戳。
timeline.events.[].durationString该事件的精确持续时间。
timeline.events.[].startupStep.nameStringStartupStep 的名称。
timeline.events.[].startupStep.idNumber该 StartupStep 的 ID。
timeline.events.[].startupStep.parentIdNumber该 StartupStep 的父级 ID。
timeline.events.[].startupStep.tagsArray包含额外步骤信息的键值对数组。
timeline.events.[].startupStep.tags[].keyStringStartupStep 标签的键。
timeline.events.[].startupStep.tags[].valueStringStartupStep 标签的值。