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}/** 没有设置可以忽略
相关推荐
chxii1 小时前
5java集合框架
java·开发语言
weixin_545019322 小时前
微信小程序智能商城系统(uniapp+Springboot后端+vue管理端)
spring boot·微信小程序·uni-app
玉笥寻珍2 小时前
Web安全渗透测试基础知识之HTTP参数污染篇
网络·网络协议·安全·web安全·http
yychen_java2 小时前
R-tree详解
java·算法·r-tree
JANYI20183 小时前
嵌入式设计模式基础--C语言的继承封装与多态
java·c语言·设计模式
xrkhy3 小时前
反射, 注解, 动态代理
java
Ten peaches3 小时前
Selenium-Java版(操作元素)
java·selenium·测试工具·html
一只码代码的章鱼3 小时前
Spring的 @Validate注解详细分析
前端·spring boot·算法
lyw2056193 小时前
RabbitMQ,Kafka八股(自用笔记)
java
邹诗钰-电子信息工程3 小时前
嵌入式自学第二十一天(5.14)
java·开发语言·算法