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

河南省住房和城乡建设厅网站营销网站建设规划

河南省住房和城乡建设厅网站,营销网站建设规划,地下城做解封任务的网站,石碣镇做网站SpringBoot 启动输出 Git 版本信息 文章目录 SpringBoot 启动输出 Git 版本信息1. 环境依赖2. pom.xml 配置3. 启动类配置 为了方便记录项目打包时的 Git 版本,本文将介绍如何将 Git 版本信息打包进 JAR 文件,并在项目启动时输出。 1. 环境依赖 SpringB…

SpringBoot 启动输出 Git 版本信息

文章目录

  • SpringBoot 启动输出 Git 版本信息
    • 1. 环境依赖
    • 2. pom.xml 配置
    • 3. 启动类配置

为了方便记录项目打包时的 Git 版本,本文将介绍如何将 Git 版本信息打包进 JAR 文件,并在项目启动时输出。

1. 环境依赖

  • SpringBoot 2.7.13;
  • git-commit-id-maven-plugin 4.9.9;

2. pom.xml 配置

<build><plugins><plugin><groupId>io.github.git-commit-id</groupId><artifactId>git-commit-id-maven-plugin</artifactId><version>4.9.9</version><executions><execution><id>get-the-git-infos</id><goals><goal>revision</goal></goals><phase>initialize</phase></execution></executions><configuration><injectAllReactorProjects>false</injectAllReactorProjects><verbose>true</verbose><skipPoms>true</skipPoms><generateGitPropertiesFile>true</generateGitPropertiesFile><generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties</generateGitPropertiesFilename><generateGitPropertiesFileWithEscapedUnicode>false</generateGitPropertiesFileWithEscapedUnicode><dotGitDirectory>${project.basedir}/.git</dotGitDirectory><format>properties</format><prefix>git</prefix><dateFormat>yyyy-MM-dd HH:mm:ss</dateFormat><dateFormatTimeZone>${user.timezone}</dateFormatTimeZone><failOnNoGitDirectory>false</failOnNoGitDirectory><failOnUnableToExtractRepoInfo>false</failOnUnableToExtractRepoInfo><useNativeGit>false</useNativeGit><skip>false</skip><runOnlyOnce>false</runOnlyOnce><commitIdGenerationMode>full</commitIdGenerationMode><evaluateOnCommit>HEAD</evaluateOnCommit><useBranchNameFromBuildEnvironment>true</useBranchNameFromBuildEnvironment><injectIntoSysProperties>true</injectIntoSysProperties><offline>true</offline></configuration></plugin></plugins>
</build>

3. 启动类配置

package com.xiaoqqya.gitinfo;import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.info.GitProperties;
import org.springframework.context.ConfigurableApplicationContext;/*** Spring boot git info demo.** @author <a href="mailto:xiaoQQya@126.com>xiaoQQya</a>* @since 2023/07/11*/
@SpringBootApplication
public class GitInfoApplication {private static final Logger LOGGER = LoggerFactory.getLogger(GitInfoApplication.class);public static void main(String[] args) {ConfigurableApplicationContext context = SpringApplication.run(GitInfoApplication.class, args);printGitInfo(context);}/*** 输出 Git 版本控制信息.** @param context SpringBoot 上下文信息*/private static void printGitInfo(ConfigurableApplicationContext context) {try {if (LOGGER.isInfoEnabled()) {GitProperties gitProperties = context.getBean(GitProperties.class);LOGGER.info("Git branch: {}", gitProperties.get("branch"));LOGGER.info("Git build time: {}", gitProperties.get("build.time"));LOGGER.info("Git commit id: {}", gitProperties.get("commit.id.full"));LOGGER.info("Git commit user: {}", gitProperties.get("commit.user.name") + "<" + gitProperties.get("commit.user.email") + ">");LOGGER.info("Git commit time: {}", gitProperties.get("commit.time"));LOGGER.info("Git commit message: {}", gitProperties.get("commit.message.full"));}} catch (NoSuchBeanDefinitionException e) {LOGGER.warn(e.getMessage());}}
}

参考文章:

  • git-commit-id/git-commit-id-maven-plugin (github.com);
  • Injecting Git Information Into Spring Beans | Baeldung;
  • springboot获取项目git版本信息的几种方式_gitproperties_sky~hello的博客-CSDN博客;
http://www.dt0577.cn/news/18652.html

相关文章:

  • 杭州网站模板国内网站排名
  • 山西省和城乡建设厅网站百度网盘破解版
  • 克隆网站首页做单页站几个文件广告传媒公司
  • 网站建设公众号开培训心得体会总结简短
  • 如何进行网站建设分析seo优化专家
  • 做的比较好的返利网站知乎太原做网站的工作室
  • 中国做健身补剂的网站百度竞价开户需要多少钱
  • 体验好的网站app注册拉新平台
  • 给蛋糕店做企业网站的文案杭州余杭区抖音seo质量高
  • 支付宝签约网站百度游戏官网
  • 记事本做网站文字居中优化关键词排名哪家好
  • 客户在我这做的网站被罚比较好的网络优化公司
  • 网页设计学习心得班级优化大师功能介绍
  • 做企业宣传网站公司如何进行搜索引擎优化 简答案
  • 创建一个网站英语百度关键词排名突然没了
  • 那个网站可以做攻略长沙服务好的网络营销
  • 怎样建设一个公司网站百度seo效果
  • wordpress部署到威望广州网站制作实力乐云seo
  • 做网站用的小图标千锋教育培训收费一览表
  • 美丽说网站案例分析建站网站关键词优化
  • 网站添加ip访问限制吗推广赚钱一个50元
  • 加盟网站制作seo招聘
  • 深圳网站开发怎么样网站域名解析ip查询
  • 晋中市政府网站集约化建设拉新推广渠道
  • 做立体字的网站怎么看百度关键词的搜索量
  • 怎么做消费一卡通网站技术培训机构排名前十
  • 淘宝在哪个网站做推广网页开发流程
  • 建设h网站风险大吗技能培训机构排名前十
  • 怎么建立一个网站让百度搜到网上推
  • 郑州网站制作企业香港服务器