You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Grails 3.3.11集成Spring Boot Actuator访问health端点404求助

问题根因

Grails 3.3.11 底层基于 Spring Boot 1.5.x 版本,你当前使用的是 Spring Boot 2.x 版本的 Actuator 配置规则,和底层依赖不兼容,同时 Grails DispatcherServlet 默认会拦截所有请求,导致 Actuator 的接口没有被正确映射。

解决方案

步骤1:修正 application.yml 配置

替换你现有的 endpoints 相关配置为适配 Spring Boot 1.5.x 的规则,同时配置 Grails 拦截排除规则:

# Actuator 核心配置
endpoints:
  enabled: true
  health:
    enabled: true
    sensitive: false # 无需鉴权即可访问设为false,需要鉴权的场景保留默认true
management:
  security:
    enabled: false # 不需要全局鉴权的场景关闭,根据你的实际业务调整
  context-path: /actuator # 指定Actuator接口的统一前缀,和你要访问的路径匹配

# Grails 拦截排除配置,避免Actuator请求被Grails Dispatcher拦截
grails:
  web:
    dispatcher:
      excludeUrlPatterns:
        - /actuator/*
        - /actuator/**

步骤2:确认依赖版本正确性

不要手动指定 Actuator 的版本,直接使用 Grails 统一管理的 Spring Boot 依赖版本即可,避免版本冲突:

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

步骤3:验证访问

重启应用后访问 {base_url}/cmbid/actuator/health 即可正常获取健康信息。

内容的提问来源于stack exchange,提问作者D Nunes

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.06 06:09:03