弹簧执行器:/ info时间戳格式

问题描述

我向我的spring项目中添加了spring boot作动器依赖项,并添加generate git properties插件

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

  <build>
 <plugins>
      <plugin>
        <groupId>pl.project13.maven</groupId>
        <artifactId>git-commit-id-plugin</artifactId>
        <version>3.0.1</version>
        <executions>
          <execution>
            <id>get-the-git-infos</id>
            <goals>
              <goal>revision</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <verbose>false</verbose>
          <generateGitPropertiesFile>true</generateGitPropertiesFile>
          <failOnNoGitDirectory>false</failOnNoGitDirectory>
        </configuration>
</plugins>
  </build>

git.properties文件生成符合预期,但是当我调用/actuator/info时得到响应

{
    "git": {
        "commit": {
            "time": 1597929440.000000000,"id": "a043f4c"
        },"branch": "test"
    },"build": {
        "version": "1.0-SNAPSHOT","artifact": "artificat","name": "module","group": "com.example.configuration","time": 1597996624.271000000
    }
}

时间戳以epocs而不是实际的时间格式出现,according to here spring将日期转换为时间戳,并让jackson将时间戳转换回日期,但似乎没有(我一定很想念很明显的东西),这是杰克逊的配置

        ObjectMapper mapper = new ObjectMapper();
        mapper.registerModule(new Jdk8Module());
        mapper.registerModule(new JavaTimeModule());
        mapper.setSerializationInclusion(Include.NON_NULL);
        mapper.setSerializationInclusion(Include.NON_EMPTY);
        mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
        return mapper;

我如何将时间戳转换为可读格式?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)