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}/** 没有设置可以忽略
相关推荐
皮皮林5511 天前
Java性能调优黑科技!1行代码实现毫秒级耗时追踪,效率飙升300%!
java
冰_河1 天前
QPS从300到3100:我靠一行代码让接口性能暴涨10倍,系统性能原地起飞!!
java·后端·性能优化
桦说编程1 天前
从 ForkJoinPool 的 Compensate 看并发框架的线程补偿思想
java·后端·源码阅读
躺平大鹅1 天前
Java面向对象入门(类与对象,新手秒懂)
java
初次攀爬者1 天前
RocketMQ在Spring Boot上的基础使用
java·spring boot·rocketmq
花花无缺1 天前
搞懂@Autowired 与@Resuorce
java·spring boot·后端
Derek_Smart1 天前
从一次 OOM 事故说起:打造生产级的 JVM 健康检查组件
java·jvm·spring boot
NE_STOP1 天前
MyBatis-mybatis入门与增删改查
java
孟陬2 天前
国外技术周刊 #1:Paul Graham 重新分享最受欢迎的文章《创作者的品味》、本周被划线最多 YouTube《如何在 19 分钟内学会 AI》、为何我不
java·前端·后端