maven 版本发布添加上时间戳

 

使用插件添加时间戳

我使用的是spring boot - 2.0.3.RELEASE版本

pom中加入

<!--
加入这个 就可以直接在配置文件中取到时间戳了,
注意: 由于${}方式会被maven处理。 如果你pom继承了spring-boot-starter-parent, Spring Boot已经将maven-resources-plugins默认的${}方式改为了@@方式,例如:@timestamp@ --> <properties> <project.build.version>@timestamp@</project.build.version> </properties> <build> <finalName>${artifactId}_${timestamp}</finalName> <plugins>       ..... <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>buildnumber-maven-plugin</artifactId> <version>1.4</version> <configuration> <timestampFormat>yyyyMMddHHmmss</timestampFormat> </configuration> <executions> <execution> <goals> <goal>create-timestamp</goal> </goals> </execution> </executions> <inherited>false</inherited> </plugin> </plugins> ..... </build>

  

现在只需要在配置文件加入(用的的是.yml)

project:
    build:
      version: @project.build.version@

如果是.properties文件
project.build.version= @project.build.version@

原文地址:https://www.cnblogs.com/collin/p/10210773.html