[英]Spring Boot remove extra HealthIndicator information
I just add a spring-boot-starter-actuator dependency to pom.xml of my application. 我只是将spring-boot-starter-actuator依赖项添加到我的应用程序的pom.xml中。 After building and running project, /health endpoint showing the next information: 构建并运行项目后,/ health endpoint显示下一个信息:
{
"status": "UP",
"details": {
"application": {
"status": "UP"
}
},
"application": {
"status": "UP"
}
}
How can I remove the "details" section from response? 如何从响应中删除“详细信息”部分?
Finally I found the root cause of the problem. 最后我找到了问题的根本原因。 It was incorrect configuration of MappingJackson2HttpMessageConverter: 这是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. “详细信息”字段是私有的并存储在Health.class中,但是使用此配置,它被添加到最终的json响应中。 I removed that and now everything works fine. 我删除了,现在一切正常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.