簡體   English   中英

Spring 啟動應用程序/執行器/刷新返回 404

[英]Spring boot application /actuator/refresh return 404

事實:

  • 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正在返回有效響應。

{“狀態”:“UP”}

編輯:我發現 /actuator/refresh 正在使用以下 spring 引導版本及以下 使用較新的版本直到現在沒有成功

   <version>2.3.12.RELEASE</version>

編輯2:

spring 通過 2.4.0 啟動沒有refresh端點

  1. 該文檔說所有端點默認情況下都可用,除了關閉

默認情況下,除了關閉之外的所有端點都已啟用。 要配置端點的啟用,請使用其 management.endpoint..enabled 屬性。 以下示例啟用關閉端點:

https://docs.spring.io/spring-boot/docs/current/reference/html/actuator.html#actuator.endpoints.enabling

  1. 端點列表中未提及刷新端點https://docs.spring.io/spring-boot/docs/current/reference/html/actuator.html#actuator.endpoints.exposing

  2. 如果您想擁有新的自定義端點,spring 執行器提供了一種方法:

     @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; } }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM