1. 程式人生 > >springboot 2.0 config client 重新整理問題

springboot 2.0 config client 重新整理問題

 

按照下面這個案例練習spring boot 的configure Server 、 config client, 發現修改配置檔案後,不能看到重新整理的結果。 記錄一下解決思路。

https://www.tutorialspoint.com/spring_boot/spring_boot_cloud_configuration_client.htm

 

問題:

手動修改config-client.properties的內容後,重新整理 config Server URL:  http://localhost:8888/config-client/default/master, 修改的內容可以被顯示過來,

但是重新整理config client URL: http://localhost:8080/, 看到的還是修改前的內容。

嘗試用postman發訊息給http://localhost:8080/refresh, 然後再重新整理http://localhost:8080/, 看到的還是修改前的內容。沒有變化。

而且Post給http://localhost:8080/refresh,返回的是404錯誤

解決:

網上一頓搜,發現有的是post給server 有的是post給client,但是都不好使。

嘗試一下URL均不好使
http://localhost:8080/refresh
http://localhost:8080/actuator/bus-refresh
http://localhost:8888/actuator/bus-refresh

修改配置檔案後,http://localhost:8888/config-client/default/master,可以顯示修改的內容,所以很大可能是問題發生在config client。

參照網上的配置,在config client的配置檔案中新增暴露endpoint.

management.endpoints.web.exposure.include= *

 

仔細觀察config client的log(eclipse的console log)發現這裡列印的所以暴露的URL。

2018-10-20 11:49:32.524  INFO 9940 --- [           main] s.b.a.e.w.s.WebMvcEndpointHandlerMapping : Mapped "{[/actuator/threaddump],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.web.servlet.AbstractWebMvcEndpointHandlerMapping$OperationHandler.handle(javax.servlet.http.HttpServletRequest,java.util.Map<java.lang.String, java.lang.String>)
2018-10-20 11:49:32.525  INFO 9940 --- [           main] s.b.a.e.w.s.WebMvcEndpointHandlerMapping : Mapped "{[/actuator/metrics/{requiredMetricName}],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.web.servlet.AbstractWebMvcEndpointHandlerMapping$OperationHandler.handle(javax.servlet.http.HttpServletRequest,java.util.Map<java.lang.String, java.lang.String>)
2018-10-20 11:49:32.526  INFO 9940 --- [           main] s.b.a.e.w.s.WebMvcEndpointHandlerMapping : Mapped "{[/actuator/metrics],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.web.servlet.AbstractWebMvcEndpointHandlerMapping$OperationHandler.handle(javax.servlet.http.HttpServletRequest,java.util.Map<java.lang.String, java.lang.String>)
2018-10-20 11:49:32.526  INFO 9940 --- [           main] s.b.a.e.w.s.WebMvcEndpointHandlerMapping : Mapped "{[/actuator/scheduledtasks],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.web.servlet.AbstractWebMvcEndpointHandlerMapping$OperationHandler.handle(javax.servlet.http.HttpServletRequest,java.util.Map<java.lang.String, java.lang.String>)
2018-10-20 11:49:32.527  INFO 9940 --- [           main] s.b.a.e.w.s.WebMvcEndpointHandlerMapping : Mapped "{[/actuator/httptrace],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.web.servlet.AbstractWebMvcEndpointHandlerMapping$OperationHandler.handle(javax.servlet.http.HttpServletRequest,java.util.Map<java.lang.String, java.lang.String>)
2018-10-20 11:49:32.529  INFO 9940 --- [           main] s.b.a.e.w.s.WebMvcEndpointHandlerMapping : Mapped "{[/actuator/mappings],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.web.servlet.AbstractWebMvcEndpointHandlerMapping$OperationHandler.handle(javax.servlet.http.HttpServletRequest,java.util.Map<java.lang.String, java.lang.String>)
2018-10-20 11:49:32.530  INFO 9940 --- [           main] s.b.a.e.w.s.WebMvcEndpointHandlerMapping : Mapped "{[/actuator/refresh],methods=[POST],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.web.servlet.AbstractWebMvcEndpointHandlerMapping$OperationHandler.handle(javax.servlet.http.HttpServletRequest,java.util.Map<java.lang.String, java.lang.String>)
2018-10-20 11:49:32.531  INFO 9940 --- [           main] s.b.a.e.w.s.WebMvcEndpointHandlerMapping : Mapped "{[/actuator/features],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.web.servlet.AbstractWebMvcEndpointHandlerMapping$OperationHandler.handle(javax.servlet.http.HttpServletRequest,java.util.Map<java.lang.String, java.lang.String>)
2018-10-20 11:49:32.535  INFO 9940 --- [           main] s.b.a.e.w.s.WebMvcEndpointHandlerMapping : Mapped "{[/actuator],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}" onto protected java.util.Map<java.lang.String, java.util.Map<java.lang.String, org.springframework.boot.actuate.endpoint.web.Link>> org.springframework.boot.actuate.endpoint.web.servlet.WebMvcEndpointHandlerMapping.links(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2018-10-20 11:49:32.722  INFO 9940 --- [           
Mapped "{[/actuator/refresh],methods=[POST]

所以修改 postman 重新整理的URL為: http://localhost:8080/actuator/refresh, 是post訊息

再次重新整理http://localhost:8080/的時候就看到了更新過的內容。

 

 

Config Server 重新整理看到的內容

重新整理config client 看到的內容