【问题标题】:Grails 3.3.11 and Spring boot actuator do not work for health endpointGrails 3.3.11 和 Spring boot 执行器不适用于健康端点
【发布时间】:2021-08-25 18:26:47
【问题描述】:

我正在尝试在我的 grails 3.3.11 rest-api 应用程序中配置 Spring boot actuator,以便获得有关它的运行状况信息。但是当我访问 {base_url}/cmbid/actuator/health 时,我会收到这样的 404 响应

2021-08-25 15:13:18.980  WARN --- [nio-8081-exec-1] o.s.web.servlet.PageNotFound             : No mapping found for HTTP request with URI [/cmbid/actuator/health] in DispatcherServlet with name 'grailsDispatcherServlet'

下面,我可以向您展示一些相关信息。 Grails 版本 3.3.11 这是一个rest-api配置文件应用程序

在我的 build.gradle 文件中我是这样配置的

dependencies {
     compile "org.springframework.boot:spring-boot-starter-actuator"
}

在我的 application.yml 文件中我是这样配置的。

endpoints:
    health:
        enabled: true
    web:
        exposure:
        include: health
    jmx:
        enabled: true
        unique-names: true

我不知道问题出在哪里,但在我的 grails 4.0.3 中它按预期工作。唯一的区别是,在 Grails 4.0.3 中,application.yml 有一个管理条目,就像这样。

management:
    endpoints:
        enabled-by-default: true
    endpoint:
        health:
            show-details : always

我从 grails 3.3.11 应用程序中删除了管理条目,因为它不起作用,而且我在 Internet 文档中看到,如果您将端点条目放在 application.yml 的根目录中,它将起作用。

很遗憾,我不知道发生了什么。

你能帮帮我吗?

【问题讨论】:

    标签: spring-boot grails spring-boot-actuator


    【解决方案1】:

    看来您可能禁用了端点。能否请您验证以下配置是否设置为true

    endpoints:
        enabled: true
    

    我刚刚使用 Grails 3.3.11 REST API 应用程序进行了测试,该应用程序正确返回响应为:

    curl -XGET localhost:8080/健康

    {
      "status": "UP"
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-03-10
      • 2015-07-04
      • 2017-05-18
      • 1970-01-01
      • 2019-05-29
      • 1970-01-01
      • 2015-08-24
      相关资源
      最近更新 更多