When I access the /health
endpoint from my Spring Boot application (1.2.4.RELEASE) it is returning a status of DOWN
:
{
status: \"DO
I got this fixed using below code.
Wrote a controller which accepts "/private/health" mapping (You can use /health instead).
import io.swagger.annotations.Api;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping
@Api(value = "Heath Service Health", description = "Heath Service Health")
public class HeathController {
@GetMapping(value = "/private/health")
@ResponseStatus(HttpStatus.OK)
HealthStatusDto healthCheck() {
return HealthStatusDto.builder().status("UP").build();
}
}
Below class is optional. Instead of returning HealthStatusDto in above controller you can return any other message as a String.
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
@Data
@AllArgsConstructor
@Builder
public final class HealthStatusDto {
private final String status;
}
Add below config in application.yml
# actuator
# Disable Spring security
management:
security:
enabled: false
# Disable actuators
endpoints:
actuator:
enabled: false
enabled: false
Hope this helps