当前位置: 首页 > 知识库问答 >
问题:

Spring Boot执行器endpoint未通过HTTP公开

荣曾笑
2023-03-14

我们是关于Spring Boot1.5.2应用程序和执行器endpoint的一些问题。

有时,当我们启动Spring Boot应用程序时,spring mvc不会通过HTTP公开执行器endpoint。我没有找到任何模式,我新启动了相同的应用程序3或4次,以便公开这些endpoint。

    null
compile 'org.springframework.boot:spring-boot-starter-actuator'

application.yml中的配置:

management:
    context-path: /private/actuator
    security:
        enabled: false

在日志中,我们希望找到如下所示:

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

共有1个答案

高云瀚
2023-03-14

尝试设置其曝光:

management:
  server:
    servlet:
      context-path: /manage
   endpoints:
      web:
        exposure:
            include: '*'
 类似资料:
  • 我正在将一个旧的java Spring项目重构为springboot,并以传统的war风格部署它。出于某种原因,我必须坚持传统的web.xml来启动应用程序。多亏了Springboot遗产,我可以通过web.xml实现这一点: 此外,我添加了springboot执行器依赖项。应用程序。属性如下所示: 应用程序可以正常启动,但当我尝试从浏览器访问endpoint时,它只返回一个“401需要完全身份验

  • 我正试图把普罗米修斯加入我的Spring靴项目。我正在使用Spring Boot执行器来公开度量endpoint。我按照教程做了所有的事情,但我总是得到一个404错误。我还尝试了中给出的每一个解决方案: context.xml(外部属性):

  • 我希望所有执行器endpoint(在文档中描述)都可用。在文档之后,添加了启动器启动器依赖项和属性,但大多数endpoint不可用(HTTP 404)。 唯一可用的endpoint是,但它显示无用的信息: 添加属性。 添加了依赖项: 获取/执行器的结果 启用执行器endpoint的最小设置是什么?

  • 调用GET /actuator/logfile返回404错误。 我如何通过执行器/日志文件获取日志? 我有下面的配置。 我使用“本地”配置文件启动了应用程序。 我有日志文件在日志文件夹(例如api_log.2020-09-22-0.log)。 应用yml公司 logback-spring.xml 日志/file.xml /执行器/日志文件endpoint启用。

  • 在Spring Boot应用程序中,我想通过从插件任务中获取执行器endpoint中的构建和其他应用程序相关信息。但是,构建信息属性文件名不是,而是不同的。属性文件存在于Spring引导创建的胖罐中的中。 我的问题是:有没有什么方法可以在任务中配置属性文件名而不是采用默认值? 更新: