> For the complete documentation index, see [llms.txt](https://jack80342.gitbook.io/spring-boot/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jack80342.gitbook.io/spring-boot/ix.-how-to-guides/86.-build/86.1-generate-build-information.md).

# 86.1 生成构建信息

Maven插件和Gradle插件都支持产生包含项目版本、坐标、名称的构建信息。该插件可以通过配置添加其他属性。当这些文件出现时，Spring Boot自动配置一个`BuildProperties` bean。

为了让Maven生成构建信息，你需要为`build-info` goal添加一个execution：

```markup
<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <version>2.0.0.RELEASE</version>
            <executions>
                <execution>
                    <goals>
                        <goal>build-info</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
```

**注** 更多详情查看[Spring Boot Maven插件文档](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/maven-plugin)。

使用Gradle实现同样效果：

```
springBoot {
    buildInfo()
}
```

**注** 更多详情查看[Spring Boot Gradle插件文档](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/gradle-plugin/reference/html/#integrating-with-actuator-build-info)。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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.1-generate-build-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.
