利用Maven添加工程版本信息及時(shí)間戳
Maven添加工程版本信息及時(shí)間戳
定義全局變量
pom文件中添加
<properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.build.number>1.0.5</maven.build.number> <maven.build.timestamp.format>yyyy-MM-dd HH:mm:ss</maven.build.timestamp.format> </properties>
給MANIFEST.MF文件添加版本及時(shí)間戳信息
pom文件中添加
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<!-- 如果是jar包值為true,如果是war包值為false -->
<archiveClasses>false</archiveClasses>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
</manifest>
<manifestEntries>
<Build-Number>${maven.build.number}</Build-Number>
<Timestamp>${maven.build.timestamp}</Timestamp>
</manifestEntries>
</archive>
</configuration>
</plugin>
Maven版本發(fā)布添加上時(shí)間戳
使用插件添加時(shí)間戳
我使用的是spring boot - 2.0.3.RELEASE版本
pom中加入
<!--
加入這個(gè) 就可以直接在配置文件中取到時(shí)間戳了,注意:
由于${}方式會(huì)被maven處理。
如果你pom繼承了spring-boot-starter-parent,
Spring Boot已經(jīng)將maven-resources-plugins默認(rèn)的${}方式改為了@@方式,例如:@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>
現(xiàn)在只需要在配置文件加入(用的的是.yml)
project:
build:
version: @project.build.version@<br><br>如果是.properties文件
project.build.version= @project.build.version@
以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
解決mybatis三表連接查詢數(shù)據(jù)重復(fù)的問題
這篇文章主要介紹了解決mybatis三表連接查詢數(shù)據(jù)重復(fù)的問題,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2021-01-01
SpringMVC上傳文件的三種實(shí)現(xiàn)方式
本篇文章主要介紹了SpringMVC上傳文件的三種實(shí)現(xiàn)方式,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2016-12-12
java Servlet 實(shí)現(xiàn)動(dòng)態(tài)驗(yàn)證碼圖片示例
這篇文章主要介紹了java Servlet 實(shí)現(xiàn)動(dòng)態(tài)驗(yàn)證碼圖片示例的資料,這里整理了詳細(xì)的代碼,有需要的小伙伴可以參考下。2017-02-02
JavaWeb中HttpSession中表單的重復(fù)提交示例
這篇文章主要介紹了JavaWeb中HttpSession中表單的重復(fù)提交,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2017-03-03
java并發(fā)學(xué)習(xí)-CountDownLatch實(shí)現(xiàn)原理全面講解
這篇文章主要介紹了java并發(fā)學(xué)習(xí)-CountDownLatch實(shí)現(xiàn)原理全面講解,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2021-02-02
SpringBoot集成validation校驗(yàn)參數(shù)遇到的坑
這篇文章主要介紹了SpringBoot集成validation校驗(yàn)參數(shù)遇到的坑,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-12-12
spring boot 集成 shiro 自定義密碼驗(yàn)證 自定義freemarker標(biāo)簽根據(jù)權(quán)限渲染不同頁面(推薦
這篇文章主要介紹了spring-boot 集成 shiro 自定義密碼驗(yàn)證 自定義freemarker標(biāo)簽根據(jù)權(quán)限渲染不同頁面,需要的朋友可以參考下2018-12-12

