事实:
- SpringBoot版本:2.5.6
- 添加到pom.xml的执行器依赖项
- 在application.yaml中,将启用端点:
management: endpoints: web: exposure: include: '*'
如果我进行curl -X POST localhost:8080/actuator/refresh
,则会得到以下响应:
> "timestamp":"2022-01-20T13:32:48.516+00:00","status":404,"error":"Not
> Found","path":"/actuator/refresh"}
我已经查看了关于这个话题的所有帖子,并尝试了所有可能的解决方案,但直到现在都没有成功。我在哪里失败?
PS:curl localhost:8080/actuator/health
正在返回一个有效的响应。
{"状态":"向上"}
编辑:我发现/actuator/refresh适用于以下弹簧引导版本及以下版本到目前为止,更新的版本没有成功的
<version>2.3.12.RELEASE</version>
编辑2:
2.4.0以上的弹簧引导没有refresh
端点
编辑3:具有以下depsCCD_ 4和CCD_编辑4:执行器是一个弹簧云属性,因此,它应该是可用的其依赖
- 文档说,除了关闭之外,所有端点默认都可用
默认情况下,除关闭外,所有端点都处于启用状态。到配置端点的启用,使用其management.endpoint..已启用属性。以下示例启用关闭端点:
https://docs.spring.io/spring-boot/docs/current/reference/html/actuator.html#actuator.endpoints.enabling
-
刷新端点未在端点列表中提及https://docs.spring.io/spring-boot/docs/current/reference/html/actuator.html#actuator.endpoints.exposing
-
如果你想有新的自定义端点,弹簧执行器提供了一种方法:
@Component @Endpoint(id="custom-endpoint") public class CustomEndPoint { @ReadOperation public CustomData customEndpoint() { // you have to define this class CustomData CustomData data = new CustomData(); // ... set some attributes return data; } }