【问题标题】:Spring-boot 2.0.0 M1 - Actuator not workingSpring-boot 2.0.0 M1 - 执行器不工作
【发布时间】:2017-11-10 15:24:16
【问题描述】:

我有一个 Spring-boot 项目,它使用 spring-boot 执行器来提供应用程序统计信息和指标。

通过向项目添加“spring-boot-starter-actuator”来提供执行器功能。

此时,security被禁用,所以项目没有导入spring-security。

使用 spring-boot 1.5.x,所有执行器端点(自动提供,如 /info,以及我特定定义的端点)都可以正常工作。

更新到 Spring-boot 2.0.0 M1 后,执行器端点不再暴露。调用 /info 端点会返回以下错误:

{"timestamp":1496948526890,"status":404,"error":"Not Found","message":"No 
message available","path":"/info"}

关于 Tomcat 的说明:我正在重新定义 tomcat.version 属性,以便使用版本 9。

  • 使用 spring-boot 1.5.x 时,tomcat.version=9.0.0.M9
  • 使用spring-boot 2.0.0.M1时,tomcat.version=9.0.0.M21

【问题讨论】:

  • 在不覆盖 Tomcat 版本时这是否有效?我不确定 Spring Boot 是否正式支持这个版本。
  • 删除覆盖时,spring-boot 使用 Tomcat 版本 8.5.15。不幸的是,我遇到了同样的错误。我已将日志级别更改为 TRACE,请您查看日志,看看您是否可以发现任何内容?请在此处下载日志:meocloud.pt/link/4d4c29c6-dc77-4b64-9ef4-fb14038836a7/log.log

标签: spring-boot spring-boot-actuator


【解决方案1】:

它又被移动了。目前,URL 位于/actuator 下,例如:/actuator/health

https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#production-ready-endpoints

【讨论】:

    【解决方案2】:

    看起来端点不再映射到 /info

    2017-06-08 13:11:57.817 [main] INFO o.s.b.a.e.mvc.EndpointHandlerMapping - Mapped "{[/application/info || /application/info.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v2+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()

    根据 2.0.0/SNAPSHOT 文档,这是预期的。

    https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#production-ready-endpoints

    试试/application/info

    【讨论】:

    • 完美,它工作正常。非常感谢您的帮助。
    • 斯蒂芬,谢谢你的链接。我实际上阅读了该页面,但我不得不承认我错过了执行器部分。我看到我可以使用 management.context-path 属性来覆盖默认设置。
    【解决方案3】:

    试试这个

    management: endpoints: web: exposure: include: '*' base-path: /actuator

    【讨论】:

      【解决方案4】:

      您甚至可以使用管理属性定义特定路径:

      management.context-path =

      如果您设置一个空白区域,您可以随意访问“/info”

      【讨论】:

        猜你喜欢
        • 2014-09-11
        • 1970-01-01
        • 2018-12-31
        • 2018-08-13
        • 1970-01-01
        • 1970-01-01
        • 2018-08-26
        • 2014-04-07
        • 2018-04-22
        相关资源
        最近更新 更多