> 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/v.-spring-boot-actuator/50.-endpoints/50.10-application-information/50.10.5-writing-custom-infocontributors.md).

# 50.10.5 编写自定义的InfoContributor

你可以注册实现了[`InfoContributor`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/info/InfoContributor.java)接口的Spring bean，来提供自定义应用信息。以下示例暴露一个只有单个值的`example`实体：

```java
import java.util.Collections;

import org.springframework.boot.actuate.info.Info;
import org.springframework.boot.actuate.info.InfoContributor;
import org.springframework.stereotype.Component;

@Component
public class ExampleInfoContributor implements InfoContributor {

    @Override
    public void contribute(Info.Builder builder) {
        builder.withDetail("example",
                Collections.singletonMap("key", "value"));
    }

}
```

如果到达`info`端点，你应该可以看到包含以下实体的响应：

```javascript
{
    "example": {
        "key" : "value"
    }
}
```
