Why is the shutdown endpoint not enabled in my application?



I am trying to add a shutdown endpoint actuator/shutdown in my Spring application as explained in this tutorial so that I can gracefully shutdown the application using a call like curl -X POST localhost:8080/actuator/shutdown.

I added

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

to my pom.xml and

management:
  endpoints.web.exposure.include: *
  endpoint.shutdown.enabled: true
endpoints.shutdown.enabled: true
management.endpoint.shutdown.enabled: true

to src/main/resources/application.yaml.

But when I run curl -X POST localhost:8080/actuator/shutdown, I get the following response:

{"timestamp":"2020-04-10T10:49:36.758+0000","status":404,"error":"Not Found",
"message":"No message available","path":"/actuator/shutdown"}

I don’t see the shutdown endpoint at http://localhost:8080/actuator:

Screenshot of actuator endpoints

What am I doing wrong? What do I need to change in order for the actuator/shutdown endpoint to appear?

Answer

It appears you are using yaml, * has a special meaning in yaml and must be quoted.

The following should work

management:
  endpoint:
    shutdown:
      enabled: true
  endpoints:
    web:
      exposure:
        include: "*"


Source: stackoverflow