2016-02-17 32 views
3

我將endpoints.health.path屬性設置爲/ping/me。但我無法使用http://localhost:9000/ping/me 訪問端點,它僅適用於http://localhost:9000/health。我錯過了什麼? 以下是應用程序屬性文件中的代碼。Spring Boot - 將/ health端點的位置更改爲/ ping/me

#Configuration for Health endpoint 
endpoints.health.id=health 
endpoints.health.path=/ping/me 
endpoints.health.enabled=true 
endpoints.health.sensitive=false 

#Manage endpoints 
management.port=9000 
management.health.diskspace.enabled=false 

我得到的迴應是:

{ 
"timestamp" : 1455736069839, 
"status" : 404, 
"error" : "Not Found", 
"message" : "Not Found", 
"path" : "/ping/me" 
} 

回答

2

MvcEndpoints負責其afterPropertiesSet方法讀取endpoints.{name}.path配置和莫名其妙:

for (Endpoint<?> endpoint : delegates) { 
      if (isGenericEndpoint(endpoint.getClass()) && endpoint.isEnabled()) { 
       EndpointMvcAdapter adapter = new EndpointMvcAdapter(endpoint); 
       String path = this.applicationContext.getEnvironment() 
         .getProperty("endpoints." + endpoint.getId() + ".path"); 
       if (path != null) { 
        adapter.setPath(path); 
       } 
       this.endpoints.add(adapter); 
      } 
} 

它從設定endpoints.health.path拒絕,因爲返回falseHealthEndpoint。也許這是一個錯誤或什麼的。

更新:顯然這是一個錯誤,並得到修復在1.3.3.RELEASE版本。因此,您可以在此版本中使用/ping/me作爲您的健康監控路徑。

+0

它沒有幫助。應用程序拋出綁定錯誤 –

+0

你使用'/ ping/me'嗎?它仍然是一個'id',你不能在'id'中使用'/' –

+0

將id設置爲'ping'並且'ping'的路徑起作用。但是我不能指定像'ping-me'這樣的連字符。我試圖基於spring啓動文檔的文檔:「例如,要將/ health端點的位置更改爲/ ping/me,您可以設置endpoints.health.path =/ping/me」 –

相關問題