我在spring引导application.yml中配置了以下属性
info:
app:
name: @project.artifactId@
description: @project.description@
version: @project.version@
timestamp: @timestamp@在添加Spring依赖项之后,我能够访问/info端点并查看信息。
为了显示时间戳信息,我将下面的属性添加到maven项目的pom.xml中,如下所示
<properties>
<timestamp>${maven.build.timestamp}</timestamp>
<maven.build.timestamp.format>yyyy-MM-dd'T'HH:mm:ss'Z'</maven.build.timestamp.format>
</properties>时间戳的格式是正确的,但不是正确的。我的意思是我在IST时区,值显示为,时间戳:"2017-10-03T16:24:02Z“,这是不正确的,可能是以格林尼治时间格式显示的。但是我想要IST格式。
有人能帮我吗?
发布于 2017-10-03 19:29:21
默认情况下,Maven在UTC中发出maven.build.timestamp。
您可以使用Maven构建帮助插件的Maven构建帮助插件目标在不同的时区中发出时间戳。
下面是一个例子:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>timestamp-property</id>
<goals>
<goal>timestamp-property</goal>
</goals>
<configuration>
<name>build.timestamp.with.offset</name>
<pattern>yyyy-MM-dd'T'HH:mm:ss'Z'</pattern>
<timeZone>IST</timeZone>
</configuration>
</execution>
</executions>
</plugin>我刚刚运行了一个内置插件,并在您的问题中定义了属性,我正在响应timestamp属性和build.timestamp.with.offset属性的值:
[INFO] Executing tasks
[echo] [timestamp]: 2017-10-04T08:14:58Z
[echo] [build.timestamp.with.offset]: 2017-10-04T12:44:59Z这清楚地表明,默认的时间戳在UTC中,build.timestamp.with.offset在IST中。
因此,您可以使用这个插件,然后更新您的application.yaml以使用build.timestamp.with.offset属性。
https://stackoverflow.com/questions/46549357
复制相似问题