我希望我的 Spring Boot (1.2.4.RELEASE) 应用程序中的 /info
执行器端点返回 build.gradle
文件中指定的版本.
在我的 build.gradle
文件中,我有这样一行:
version = '0.0.1-SNAPSHOT'
我正在使用 yaml 配置文件。现在我在 application.yml
中复制了版本:
info:
build:
version: 0.0.1-SNAPSHOT
这可能吗?
最佳答案
将以下内容添加到 build.gradle
文件中。不需要创建 InfoContributor
类。
plugins {
id 'org.springframework.boot' version '<version>'
}
springBoot {
buildInfo()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-actuator'
etc...
}
查询 http://host:port/actuator/info
你会看到类似...
{
"build": {
"artifact": "spring-example",
"name": "spring-example",
"time": "2020-01-30T09:47:33.551Z",
"version": "0.0.1-SNAPSHOT",
"group": "com.example"
}
}
注意使用 2.2.4.RELEASE 测试
关于gradle - Gradle 文件中的 Spring Boot 执行器信息端点版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30786625/