当前位置: 首页 > news >正文

Java代码日志嵌入打包时间

通过插件生成编译时间代码,然后先compile一次生成代码,Java代码就可以引用到该时间,后面compile或者package的时候就会刷新这个时间,日志就可以打印每次编译的时间。

<plugin><groupId>org.codehaus.mojo</groupId><artifactId>build-helper-maven-plugin</artifactId><version>3.3.0</version><executions><execution><id>timestamp-property</id><phase>initialize</phase><goals><goal>timestamp-property</goal></goals><configuration><name>build.timestamp</name><pattern>yyyy-MM-dd HH:mm:ss</pattern><timeZone>Asia/Shanghai</timeZone></configuration></execution><execution><id>add-generated-sources</id><phase>generate-sources</phase><goals><goal>add-source</goal></goals><configuration><sources><source>${project.build.directory}/generated-sources/src/main/java</source></sources></configuration></execution></executions></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-antrun-plugin</artifactId><version>3.1.0</version><executions><execution><phase>generate-sources</phase><goals><goal>run</goal></goals><configuration><target><!-- 生成包含时间戳的 Java--><echo file="${project.build.directory}/generated-sources/src/main/java/com/chrollo/common/BuildTime.java">package com.chrollo.common;public class BuildTime {public static final String TIMESTAMP = "${build.timestamp}";}</echo></target></configuration></execution></executions></plugin>
http://www.xdnf.cn/news/382141.html

相关文章:

  • 【排错】dify1.3.1插件市场安装报错问题
  • 《从零开始:构建你的第一个区块链应用》
  • 什么是文件描述符(File Descriptor,FD)
  • 45.中医知识问答管理员端对话信息查看功能bug修复(1)
  • 在 Vue 3 中实现刮刮乐抽奖
  • 进阶 DFS 学习笔记
  • 地学领域中常见的数据类型总结
  • 游戏服务器出现卡顿该怎么处理?
  • 学习黑客5 分钟深入浅出理解Linux Logs [特殊字符]
  • 【C++】string类
  • leetcode0829. 连续整数求和-hard
  • CountDownLatch 并发编程中的同步利器
  • JavaScript 内存管理与垃圾回收机制
  • DB4S:一个开源跨平台的SQLite数据库管理工具
  • BufferAttribute
  • vs查看dmp崩溃信息
  • Python递归函数
  • 【TypeScript】类型别名(Type Alias)与接口类型(Interface)
  • Redisson 看门狗机制
  • Unity3D仿星露谷物语开发41之创建池管理器
  • 记录一次window2012r2安装配置oracle11g的过程-出现的错误以及解决方法
  • 谷歌学术链接
  • OSPF综合应用
  • Nginx高级配置
  • 解锁HBase:大数据存储的神秘之门
  • Linux:线程同步与互斥
  • 《Python星球日记》 第52天:反向传播与优化器
  • MySQL 数据类型全面指南:从理论到实践
  • HCIP笔记
  • Veins同时打开SUMO和OMNeT++的GUI界面