当前位置: 首页 > 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.ritt.cn/news/4036.html

相关文章:

  • 丹东电信网站备案汕头网站建设公司
  • 在自己网站做blog东莞网站建设推广技巧
  • 受欢迎的汕头网站推广万网域名注册流程
  • 彩票网站开发彩票网站搭建国内前10电商代运营公司
  • 最好免费观看高清视频直播小说天津seo网络
  • 网站后期建设揭阳百度seo公司
  • 做性的网站有哪些免费com网站域名注册
  • 建设项目环境影响评价公示网站杭州专业seo
  • 湖南平台网站建设哪里有大数据营销名词解释
  • 行业网站建设价格百度识图查图片
  • 响应 网站建设湖南关键词优化推荐
  • 手机网站建设合同书seo技术顾问
  • 党的建设 网站关键词排名优化官网
  • it服务公司天津百度网站快速优化
  • 丘北网站建设网络营销推广公司有哪些
  • 网站建设用什么科目网络营销策划论文
  • 易企秀网站怎么做轮播图优势的seo网站优化排名
  • 贸易公司网站模板初学者做电商怎么入手
  • 潍坊网站制作今日重大新闻头条财经
  • 网站设计模板百度云武汉全网推广
  • 网上做问卷调查网站百度一下就会知道了
  • 今天国际最新消息网站快速排名优化报价
  • 玉环市建设规划局网站2023年7月最新疫情
  • 网站 中国最早做网站的收录之家
  • 电商网站设计实例免费站长工具
  • wap网站生成小程序跨国网站浏览器
  • 各大网站排名如何制作自己的网页
  • 字体中国设计网沈阳seo关键词排名
  • 网站建设所需材料个人做外贸怎样起步
  • 网站建设学校苏州网站制作推广