使用Maven自带的时间戳
设置时间戳格式: 在pom.xml文件中添加时间格式配置
<properties>
<maven.build.timestamp.format>yyyy_MM_dd_HH</maven.build.timestamp.format>
</properties>
在Maven打包的plugin中引用该属性
<build>
<finalName>${project.artifactId}_${project.version}_${maven.build.timestamp}</finalName>
...
</build>
使用build-helper-maven-plugin
build-helper-maven-plugin允许用户使用不同的地区设置自定义的时间戳格式。
pom.xml的plugin中增加build-helper-maven-plugin配置
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>timestamp-property</id>
<goals>
<goal>timestamp-property</goal>
</goals>
<configuration>
<name>build.time</name>
<pattern>MM/dd/yyyy hh:mm aa</pattern>
<locale>en_US</locale>
<timeZone>America/Detroit</timeZone>
</configuration>
</execution>
</executions>
</plugin>
设置finalName
<build>
<finalName>${project.artifactId}_${project.version}_${package.time}</finalName>
</build>
把时间戳添加到包名上通过包名直接能够查看到打包的时间,方便包的查找,管理。
⬇⬇⬇ 你好,我是CainGao。一线大数据开发者,关注我一起交流场景实现 ⬇⬇⬇