How do I add things to the /info endpoint in spring boot programmatically?

spring-boot

Solution

In Spring Boot 1.4, you are able to declare `InfoContributer` beans to make this a whole lot easier:

@Component
public class ExampleInfoContributor implements InfoContributor {

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

}

See http://docs.spring.io/spring-boot/docs/1.4.0.RELEASE/reference/htmlsingle/#production-ready-application-info-custom for more info.

Problem

How do I add things to the `/info` endpoint in Spring Boot programmatically? The documentation states that this is possible for the `/health` endpoint through the use of `HealthIndicator` interface. Is there something for the `/info` endpoint as well? I would like to add operating system name and version and other runtime info there.

Original source

Related problems