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}/** 没有设置可以忽略
相关推荐
Cache技术分享1 分钟前
16. Java 如何创建、初始化和访问数组
java·后端
啾啾Fun5 分钟前
[微服务设计]2_演化式架构
java·微服务·架构
神秘的t11 分钟前
javaEE初阶————多线程进阶(2)
java·开发语言
MrWho不迷糊16 分钟前
Spring Batch 多写:分类写与组合写
spring boot·后端
MrWho不迷糊23 分钟前
Spring Batch 单元测试实战
spring boot·junit
Code哈哈笑39 分钟前
【JavaEE】SpringBoot快速上手,探秘 Spring Boot,搭建 Java 项目的智慧脚手架
java·spring boot·java-ee
Seven971 小时前
【设计模式】从火车站卖票看代理模式的实际应用
java·后端·设计模式
A阳俊yi1 小时前
SpringMVC概述以及入门案例
java·spring
开开心心就好1 小时前
能一站式搞定远程操作需求的实用工具
java·服务器·python·spring·pdf·电脑·软件
冬天vs不冷1 小时前
Spring组件实例化扩展点:InstantiationAwareBeanPostProcessor
java·后端·spring