spring_reference/V. Spring Boot Actuator/40.4.2. Git commit informat...

17 lines
824 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

### 40.4.2. Git提交信息
info端点的另一个有用特性是当项目构建完成后它可以发布关于你的git源码仓库状态的信息。如果在你的jar中包含一个git.properties文件git.branch和git.commit属性将被加载。
对于Maven用户`spring-boot-starter-parent` POM包含一个能够产生git.properties文件的预配置插件。只需要简单的将下面的声明添加到你的POM中
```xml
<build>
<plugins>
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
</plugin>
</plugins>
</build>
```
对于Gradle用户可以使用一个相似的插件[gradle-git](https://github.com/ajoberstar/gradle-git),尽管为了产生属性文件可能需要稍微多点工作。