# 86.2 生成Git信息

Maven和Gradle都支持生成一个`git.properties`文件，该文件包含项目构建时`git`源码的仓库状态。对于Maven用户来说，`spring-boot-starter-parent` POM包含一个预配置的插件去产生一个`git.properties`文件，只需简单的将以下声明添加到POM中：

```markup
<build>
    <plugins>
        <plugin>
            <groupId>pl.project13.maven</groupId>
            <artifactId>git-commit-id-plugin</artifactId>
        </plugin>
    </plugins>
</build>
```

Gradle用户可以使用[gradle-git-properties](https://plugins.gradle.org/plugin/com.gorylenko.gradle-git-properties)插件实现相同效果：

```
plugins {
    id "com.gorylenko.gradle-git-properties" version "1.4.17"
}
```

**注** `git.properties`中的提交时间需要符合以下格式：`yyyy-MM-dd’T’HH:mm:ssZ`。这是上面列出的两个插件的默认格式。使用这种格式可以将时间解析为`Date`，并将其格式序列化为JSON时，由Jackson的日期序列化配置设置控制。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://jack80342.gitbook.io/spring-boot/ix.-how-to-guides/86.-build/86.2-generate-git-information.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
