ieX*_*ept 5 spring-boot spring-boot-actuator
我创建了hello world Spring Boot v2.0.0.M7应用程序,添加了执行器,启用了关机,它无法正常工作.
application.properties
server.port=8082
endpoint.shutdown.enabled=true
endpoint.shutdown.sensitive=false
Run Code Online (Sandbox Code Playgroud)
健康工作正常
但不是关机
我究竟做错了什么?
Spring Boot 2.0中的端点发生了很大变化,因此您的配置已过时.您需要启用端点并通过HTTP公开它:
management.endpoints.web.expose=*
management.endpoint.shutdown.enabled=true
Run Code Online (Sandbox Code Playgroud)
正如评论中已经提到的那样,并且在Actuator HTTP API文档中进行了描述,您还需要提出POST请求,以便在浏览器中访问端点不起作用.您可以curl在命令行中使用类似的东西:
$ curl -X POST localhost:8080/actuator/shutdown
Run Code Online (Sandbox Code Playgroud)
通过阅读发行说明,您可以了解有关Spring Boot 2.0更改的更多信息.
spring-boot 2.0默认
management.endpoints.web.exposure.include=info, health,
改为
management.endpoints.web.exposure.include=info, health, shutdown
小智 5
春季启动版本:2.0.1.RELEASE
pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
Run Code Online (Sandbox Code Playgroud)
application.properties
management.endpoints.web.exposure.include=shutdown
management.endpoint.shutdown.enabled=true
Run Code Online (Sandbox Code Playgroud)
然后,尝试
$ curl -X POST localhost:8080/actuator/shutdown
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2138 次 |
| 最近记录: |