【问题标题】:Is there a way to format the spring boot build information on the info endpoint?有没有办法在 info 端点上格式化 spring boot 构建信息?
【发布时间】:2018-08-15 21:35:48
【问题描述】:
Spring Boot 允许在执行器/info 端点上公开 git 提交和构建信息。我已使用1.5.10.RELEASE integration 进行设置。
但是 info 端点上的日期被呈现为时间戳:
{"git":{
"commit":{
"time":1520441384000,
...
有没有办法将此格式自定义为更易于阅读的内容?
【问题讨论】:
标签:
java
spring
spring-boot
spring-boot-actuator
【解决方案1】:
您需要告诉 Jackson 如何在您的 application.properties(或分别为 application.yml)中序列化日期:
spring.jackson.serialization.write-dates-as-timestamps=false
但请确保您使用的是最新版本的插件,因为生成的默认日期格式是最近切换的。
这是一个完整的设置:
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<version>2.2.4</version>
<executions>
<execution>
<id>git-info</id>
<goals>
<goal>revision</goal>
</goals>
</execution>
</executions>
<configuration>
<generateGitPropertiesFile>true</generateGitPropertiesFile>
</configuration>
</plugin>