标签:default gem servlet abstract lips 配置 src 技术分享 post
按照下面这个案例练习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/refreshhttp://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 看到的内容
springboot 2.0 config client 刷新问题
标签:default gem servlet abstract lips 配置 src 技术分享 post
原文地址:https://www.cnblogs.com/louis2015/p/9821227.html