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@
    #获取项目版本
    [email protected]@
相关推荐
zhuyasen19 分钟前
深度定制 protoc-gen-go:实现结构体字段命名风格控制
后端·go·protobuf
eternal__day25 分钟前
Spring Cloud 多机部署与负载均衡实战详解
java·spring boot·后端·spring cloud·负载均衡
Livingbody35 分钟前
whisper 命令行解析【2】
后端
程序员秘密基地35 分钟前
基于vscode,idea,java,html,css,vue,echart,maven,springboot,mysql数据库,在线考试系统
java·vue.js·spring boot·spring·web app
何中应36 分钟前
【设计模式-5】设计模式的总结
java·后端·设计模式
小胖同学~1 小时前
JavaWeb笔记
后端·servlet
风象南1 小时前
SpringBoot的5种日志输出规范策略
java·spring boot·后端
cccc来财1 小时前
Go中的协程并发和并发panic处理
开发语言·后端·golang
邪恶的贝利亚2 小时前
从webrtc到janus简介
后端·asp.net·webrtc
Livingbody2 小时前
Whisper 使用简单实例教程【1】
后端