弹簧引导执行器端点未通过HTTP公开
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了弹簧引导执行器端点未通过HTTP公开相关的知识,希望对你有一定的参考价值。
我们在使用Spring Boot 1.5.2应用程序和执行器端点时遇到了一些问题。
有时当我们启动弹簧启动应用程序时,spring mvc不会通过HTTP暴露执行器端点。我没有找到任何模式,我新手启动相同的应用程序3或4次,以暴露这些端点。
在这个应用程序中我们使用:
- Java 8
- 春季启动1.5.2
- 春天4.3.7
执行器配置为build.gradle添加下一个依赖项:
compile 'org.springframework.boot:spring-boot-starter-actuator'
application.yml中的配置:
management:
context-path: /private/actuator
security:
enabled: false
在LOG中我们希望找到这样的:
2018-12-05 15:15:54.585 [restartedMain] INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/private/billing],methods=[GET]}" onto public wtn.integration.webmodel.billing.response.BillingResponse
wtn.integration.controller.BillingController.process()
2018-12-05 15:15:54.587 [restartedMain] INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/private/events/recover/{reportId}],methods=[GET]}" onto public void wtn.integration.controller.EventCon
troller.recover(java.lang.Long)
2018-12-05 15:15:54.587 [restartedMain] INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/private/events/recover/{reportId}],methods=[POST]}" onto public void wtn.integration.controller.EventCo
ntroller.recover(java.lang.Long,wtn.integration.api.event.bean.Event)
2018-12-05 15:15:54.588 [restartedMain] INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/private/events/discard/{reportId}],methods=[GET]}" onto public void wtn.integration.controller.EventCon
troller.discard(java.lang.Long)
2018-12-05 15:15:54.588 [restartedMain] INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/private/events],methods=[POST]}" onto public void wtn.integration.controller.EventController.process(wt
n.integration.api.event.request.EventRequest)
2018-12-05 15:15:54.591 [restartedMain] INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframew
ork.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2018-12-05 15:15:54.591 [restartedMain] INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.
Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2018-12-05 15:15:54.672 [restartedMain] INFO o.s.w.s.m.m.a.RequestMappingHandlerAdapter - Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationCon
text@1b7f1011: startup date [Wed Dec 05 15:15:46 CET 2018]; root of context hierarchy
2018-12-05 15:15:55.978 [restartedMain] INFO o.s.b.a.e.mvc.EndpointHandlerMapping - Mapped "{[/private/actuator/env/{name:.*}],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || appli
cation/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EnvironmentMvcEndpoint.value(java.lang.String)
2018-12-05 15:15:55.979 [restartedMain] INFO o.s.b.a.e.mvc.EndpointHandlerMapping - Mapped "{[/private/actuator/env || /private/actuator/env.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2018-12-05 15:15:55.979 [restartedMain] INFO o.s.b.a.e.mvc.EndpointHandlerMapping - Mapped "{[/private/actuator/beans || /private/actuator/beans.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2018-12-05 15:15:55.979 [restartedMain] INFO o.s.b.a.e.mvc.EndpointHandlerMapping - Mapped "{[/private/actuator/configprops || /private/actuator/configprops.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2018-12-05 15:15:55.981 [restartedMain] INFO o.s.b.a.e.mvc.EndpointHandlerMapping - Mapped "{[/private/actuator/info || /private/actuator/info.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2018-12-05 15:15:55.982 [restartedMain] INFO o.s.b.a.e.mvc.EndpointHandlerMapping - Mapped "{[/private/actuator/heapdump || /private/actuator/heapdump.json],methods=[GET],produces=[application/octet-stream]}" onto public void org.springframework.boot.actuate.endpoint.mvc.HeapdumpMvcEndpoint.invoke(boolean,javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) throws java.io.IOException,javax.servlet.ServletException
2018-12-05 15:15:55.983 [restartedMain] INFO o.s.b.a.e.mvc.EndpointHandlerMapping - Mapped "{[/private/actuator/loggers/{name:.*}],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.LoggersMvcEndpoint.get(java.lang.String)
2018-12-05 15:15:55.983 [restartedMain] INFO o.s.b.a.e.mvc.EndpointHandlerMapping - Mapped "{[/private/actuator/loggers/{name:.*}],methods=[POST],consumes=[application/vnd.spring-boot.actuator.v1+json || application/json],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.LoggersMvcEndpoint.set(java.lang.String,java.util.Map<java.lang.String, java.lang.String>)
2018-12-05 15:15:55.983 [restartedMain] INFO o.s.b.a.e.mvc.EndpointHandlerMapping - Mapped "{[/private/actuator/loggers || /private/actuator/loggers.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2018-12-05 15:15:55.984 [restartedMain] INFO o.s.b.a.e.mvc.EndpointHandlerMapping - Mapped "{[/private/actuator/health || /private/actuator/health.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.HealthMvcEndpoint.invoke(javax.servlet.http.HttpServletRequest,java.security.Principal)
2018-12-05 15:15:55.984 [restartedMain] INFO o.s.b.a.e.mvc.EndpointHandlerMapping - Mapped "{[/private/actuator/mappings || /private/actuator/mappings.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2018-12-05 15:15:55.985 [restartedMain] INFO o.s.b.a.e.mvc.EndpointHandlerMapping - Mapped "{[/private/actuator/dump || /private/actuator/dump.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
2018-12-05 15:15:55.985 [restartedMain] INFO o.s.b.a.e.mvc.EndpointHandlerMapping - Mapped "{[/private/actuator/metrics/{name:.*}],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.MetricsMvcEndpoint.value(java.lang.String)
2018-12-05 15:15:55.986 [restartedMain] INFO o.s.b.a.e.mvc.EndpointHandlerMapping - Mapped "{[/private/actuator/metrics || /private/actuator/metrics.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
但我们发现:
2018-12-05 15:27:10.713 [restartedMain] INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/private/billing],methods=[GET]}" onto public wtn.integration.webmodel.billing.response.BillingResponse
wtn.integration.controller.BillingController.process()
2018-12-05 15:27:10.715 [restartedMain] INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/private/events/discard/{reportId}],methods=[GET]}" onto public void wtn.integration.controller.EventController.discard(java.lang.Long)
2018-12-05 15:27:10.715 [restartedMain] INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/private/events/recover/{reportId}],methods=[POST]}" onto public void wtn.integration.controller.EventController.recover(java.lang.Long,wtn.integration.api.event.bean.Event)
2018-12-05 15:27:10.715 [restartedMain] INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/private/events/recover/{reportId}],methods=[GET]}" onto public void wtn.integration.controller.EventController.recover(java.lang.Long)
2018-12-05 15:27:10.715 [restartedMain] INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/private/events],methods=[POST]}" onto public void wtn.integration.controller.EventController.process(wtn.integration.api.event.request.EventRequest)
2018-12-05 15:27:10.718 [restartedMain] INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2018-12-05 15:27:10.718 [restartedMain] INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2018-12-05 15:27:10.817 [restartedMain] INFO o.s.w.s.m.m.a.RequestMappingHandlerAdapter - Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@6aedc770: startup date [Wed Dec 05 15:27:04 CET 2018]; root of context hierarchy
2018-12-05 15:27:12.156 [restartedMain] INFO o.s.j.e.a.AnnotationMBeanExporter - Registering beans for JMX exposure on startup
2018-12-05 15:27:12.158 [restartedMain] INFO o.s.j.e.a.AnnotationMBeanExporter - Bean with name 'getDataSource' has been autodetected for JMX exposure
2018-12-05 15:27:12.165 [restartedMain] INFO o.s.j.e.a.AnnotationMBeanExporter - Bean with name 'connectionFactory' has been autodetected for JMX exposure
任何的想法?
提前致谢!
答案
尝试设置曝光:
management:
server:
servlet:
context-path: /manage
endpoints:
web:
exposure:
include: '*'
以上是关于弹簧引导执行器端点未通过HTTP公开的主要内容,如果未能解决你的问题,请参考以下文章