Spring Boot remove extra HealthIndicator information

て烟熏妆下的殇ゞ 提交于 2019-12-23 17:42:55

问题


I just add a spring-boot-starter-actuator dependency to pom.xml of my application. After building and running project, /health endpoint showing the next information:

{
   "status": "UP",
   "details": {
       "application": {
           "status": "UP"
        }
    },
    "application": {
        "status": "UP"
    }
}

How can I remove the "details" section from response?


回答1:


Finally I found the root cause of the problem. It was incorrect configuration of MappingJackson2HttpMessageConverter:

@Autowired
public void configureJsonSerializer(MappingJackson2HttpMessageConverter objectMapperBuilder) {
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
    objectMapperBuilder.setObjectMapper(objectMapper);
}

The "details" field is private and stored in Health.class, but with this configuration it was added to final json response. I removed that and now everything works fine.



来源:https://stackoverflow.com/questions/46608716/spring-boot-remove-extra-healthindicator-information

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!