java Spring Boot 2 /actuator/health 返回 HTTP 404

分析健康检测接口无法访问

查看官方文档

  • spring-boot-starter-actuator官方文档

  • Spring Boot 包含许多附加功能,可帮助您在将应用程序投入生产时监控和管理应用程序。您可以选择使用 HTTP 端点或 JMX 来管理和监控您的应用程序。审核、运行状况和指标收集也可以自动应用于您的应用程序。

  • 该spring-boot-actuator模块提供了 Spring Boot 的所有生产就绪功能。启用这些功能的推荐方法是添加对spring-boot-starter-actuator"Starter"的依赖项。

导入pom文件

xml 复制代码
<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
</dependencies>

公开端点

yaml 复制代码
management:
  endpoints:
    web:
      exposure:
        include:
          - info
          - health
      jmx:
        exposure:
          exclude: "*"
  endpoint:
    info:
      enabled: true
    health:
      enabled: true

无法访问分析

  • 检查是否按照上面的步骤做了
  • 检查访问路径是否正确
    • 按照以下访问路径http://localhost:{server.port}/{server.servlet.context-path}/{management.endpoints.web.base-path}/** 没有设置可以忽略
相关推荐
PH = 78 分钟前
OverlayFS联合文件系统使用示例
java·linux·服务器
AC赳赳老秦18 分钟前
OpenClaw进阶技巧:批量修改文件内容、替换关键词,解放双手
java·linux·人工智能·python·算法·测试用例·openclaw
Java小白笔记31 分钟前
OpenClaw 实战方法论
java·开发语言·人工智能·ai·全文检索·ai编程·ai写作
m0_3801138438 分钟前
补单系统搭建及源码分享
数据库·spring boot·mybatis
呱牛do it1 小时前
企业级门户网站设计与实现:基于SpringBoot + Vue3的全栈解决方案(Day 5)
java·vue
练习时长一年1 小时前
Spring配置类的演化
java·spring boot·spring
阿丰资源1 小时前
基于SpringBoot+MySQL的社区团购系统设计与实现(附源码+文档+数据库,直接运行)
数据库·spring boot·mysql
喜欢流萤吖~1 小时前
服务间的依赖管理:微服务的协作之道
java·微服务
invicinble1 小时前
Spring如何把bean注册到容器里
java·后端·spring
阿丰资源2 小时前
基于SpringBoot+MySQL的网上订餐系统(附源码)
spring boot·后端·mysql