如何以编程方式将内容添加到Spring Boot中的/info端点? documentation指出,可以通过使用/health接口(interface)来实现HealthIndicator端点。 /info端点也有东西吗?

我想在那里添加操作系统名称和版本以及其他运行时信息。

最佳答案

在Spring Boot 1.4中,您可以声明InfoContributer bean来简化整个过程:

@Component
public class ExampleInfoContributor implements InfoContributor {

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

}

有关更多信息,请参见http://docs.spring.io/spring-boot/docs/1.4.0.RELEASE/reference/htmlsingle/#production-ready-application-info-custom

10-06 04:29
查看更多