How to make Spring Boot v2.0.0.M7 Actuator's shutdown work?

久未见 提交于 2019-12-12 10:50:34

问题


I created hello world Spring Boot v2.0.0.M7 app, added actuator, enabled shutdown and it isn't working.

application.properties

server.port=8082
endpoint.shutdown.enabled=true
endpoint.shutdown.sensitive=false

health works fine

but not the shutdown

What am I doing wrong?


回答1:


Endpoints have changed quite a bit in Spring Boot 2.0 and, as a result, your configuration is out of date. You need to enable the endpoint and also expose it over HTTP:

management.endpoints.web.expose=*
management.endpoint.shutdown.enabled=true

As already noted in the comments, and described in the Actuator HTTP API documentation, you also need to make a POST request so accessing the endpoint in your browser won't work. You can use something like curl on the command line instead:

$ curl -X POST localhost:8080/actuator/shutdown

You can learn more about changes in Spring Boot 2.0 by reading the release notes.




回答2:


spring-boot 2.0 default
management.endpoints.web.exposure.include=info, health,
change to
management.endpoints.web.exposure.include=info, health, shutdown




回答3:


spring boot version : 2.0.1.RELEASE

pom.xml

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

application.properties

management.endpoints.web.exposure.include=shutdown
management.endpoint.shutdown.enabled=true

then, try

$ curl -X POST localhost:8080/actuator/shutdown


来源:https://stackoverflow.com/questions/48192765/how-to-make-spring-boot-v2-0-0-m7-actuators-shutdown-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!