0
votes

By Default in spring boot if we hit the /actuator/health url we get the health in JSON format. But i am using jackson-dataformat-xml for my other api's in the application which makes the health url to change the response format to XML. Is there anyway we can tell spring to respond with JSON for the health url ? I do not want to add my own health url.

This question is asked sometimes before Spring Boot Actuator /env endpoint returning data as XML - why?

But did not say a good solution .

1

1 Answers

1
votes

You might try to define an ObjectMapper bean which takes precedence over the XmlMapper bean via @Primary:

@Bean
@Primary
public ObjectMapper objectMapper() {
    return new ObjectMapper();
}