I tried to use the class Health (from actuators) as response type of Spring RestTempate's method getForObject(String url, Class<AppHealth> responseType, Object... urlVariables).

The problem: An exception is thrown, because there is no default contructor for Health.

Is it possible to modify the class (Health) to work with the RestTemplate?

Or is there another simple way you can recommend to create objects out of JSON instead of using RestTemplate?

Comment From: cdupuis

Could you provide some more background on your use-case? Are you invoking the /health endpoint in some sort of monitoring app?

Comment From: dickerpulli

The use-case is, as you already anticipated, a monitoring app, that periodically calls the /health endpoint to check whether the application is working or not.

Comment From: philwebb

I think even if we added a default constructor there would be problems because the status and details fields are final and we don't provide setters. Perhaps we can provide custom deserialization support but the quickest option might be to just create your own version of the that class.

Comment From: dsyer

I would be in favour of adding a custom deserializer. But also note that best practice would probably be to use json-path (or similar) to avoid brittle coupling between the monitoring app and the service.

Comment From: MelleD

Is there now a custom deserializer?

Comment From: wilkinsona

@SirWayne Not that I'm aware of; this issue is open

Comment From: philwebb

We're cleaning out the issue tracker and closing issues that we've not seen much demand to fix. Feel free to comment with additional justifications if you feel that this one should not have been closed.

Comment From: sasaunde

I've hit this today - trying to standardise health check messages across the estate and can't customise Spring Boot messages

Comment From: wilkinsona

@sasaunde Sorry, I can't see the connection between deserialisation of JSON to a Health instance and message customization. Could you please elaborate?