Spring Boot 获取maven打包时间

  1. 引入maven打包插件

    xml 复制代码
    <build>
        <plugins>
            <!-- 打包时生成打包时间 -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>buildnumber-maven-plugin</artifactId>
                <version>3.2.0</version>
                <configuration>
                    <timestampFormat>yyyy-MM-dd HH:mm:ss</timestampFormat>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>create-timestamp</goal>
                        </goals>
                    </execution>
                </executions>
                <inherited>false</inherited>
            </plugin>
        </plugins>
    
        <!-- maven打包时包含静态资源文件 -->
        <resources>
    
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>**/*.properties</include>
                    <include>**/*.yaml</include>
                    <include>META-INF/**</include>
                    <include>**/*.xml</include>
                </includes>
                <!-- true表示maven会对文件进行过滤,将@project.version@替换为该属性的值 -->
                <filtering>true</filtering>
            </resource>
    
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.properties</include>
                    <include>**/*.xml</include>
                </includes>
                <filtering>true</filtering>
            </resource>
    
        </resources>
    </build>
    1. application.properties内引用
    properties 复制代码
    #获取build时的时间
    app.buildTime=@timestamp@
    #获取项目版本
    app.version=@project.version@
相关推荐
M1A15 小时前
小红书重磅升级!公众号文章一键导入,深度内容轻松入驻
后端
0wioiw06 小时前
Go基础(④指针)
开发语言·后端·golang
李姆斯7 小时前
复盘上瘾症:到底什么时候该“复盘”,什么时候不需要“复盘”
前端·后端·团队管理
javachen__8 小时前
Spring Boot配置error日志发送至企业微信
spring boot·后端·企业微信
seabirdssss8 小时前
使用Spring Boot DevTools快速重启功能
java·spring boot·后端
java水泥工9 小时前
校园管理系统|基于SpringBoot和Vue的校园管理系统(源码+数据库+文档)
数据库·vue.js·spring boot
令狐少侠20119 小时前
maven settings.xml文件的各个模块、含义以及它们之间的联系
xml·maven
OC溥哥99910 小时前
Flask论坛与个人中心页面开发教程完整详细版
后端·python·flask·html
栗子~~10 小时前
bat脚本- 将jar 包批量安装到 Maven 本地仓库
java·maven·jar
Mr.Entropy10 小时前
ecplise配置maven插件
java·maven