问题
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