首页 > 解决方案 > 为什么没有返回春季健康指标的详细信息?

问题描述

我目前正在使用 spring boot 2.1.4 和 jackson 2.9.8 当点击健康端点时,不显示详细信息。

{
  status: "UP"
}

我已将以下属性添加到我的配置中。

management.endpoint.health.show-details=always

当我查看环境management.endpoint.health.show-details时,它已设置。

当我监视org.springframework.boot.actuate.health.HealthWebEndpointResponseMapper.HealthWebEndpointResponseMapper(HealthStatusHttpMapper, ShowDetails, Set<String>)时,它显示ALWAYS实际上正在使用,并且没有删除细节。

但是,当它到达com.fasterxml.jackson.databind.introspect.POJOPropertiesCollector它时不会添加细节,因为该方法getDetails没有org.springframework.boot.actuate.health.HealthgetStatus(being @JsonWrapped)那样被注释

如何让 Jackson 序列化详细信息,以便可以通过健康端点返回它们?

编辑:这似乎是由在启动时注入 spring 环境的自定义 ObjectMapper 引起的,该环境将 AUTO_DETECT_GETTERS 和 AUTO_DETECT_IS_GETTERS 都设置为禁用。虽然这可能在 Spring 4 中起作用,但它似乎在 Spring 5 中不再起作用。

标签: spring-boot

解决方案


推荐阅读