I dug a bit deeper in this issue as I found it as an interesting feature of spring-boot-actuator
.
From my research I found out that this feature with liveness
and readiness
has been introduced in spring-boot:2.3.0
so if you're using an older version this might be the reason you're not receiving the expected result when you do a GET /actuator/health/readiness
.
If you upgrade your spring-boot
version to >= 2.3.0 you can enable the liveness and readiness probes by adding:
management:
health:
probes:
enabled: true
to your application.yaml file.
After doing so you should be able to
GET /actuator/health
{
"status": "UP",
"groups": [
"liveness",
"readiness"
]
}
However for spring-boot versions >= 2.3.2 it is advised to enable probes by using the following in your application.yaml
management:
endpoint:
health:
probes:
enabled: true
The reason for doing so is a bug which you can read more about here
Extra tip: If you're spring-boot
version >= 2.3.0, you've configured your application.yaml file accordingly and you still receive 404 when you GET /actuator/health/liveness
there's a slim chance that your application.yaml file is not getting picked up by the Spring Context. You can check if this is the case by changing the port of the application
server:
port: 8081
If your application doesn't start on a different port, it is safe to say that none of your configurations have taken place.
I had this issue one or two times with my IDE.