【问题标题】:Unable to access /actuator endpoints无法访问 /actuator 端点
【发布时间】:2019-12-02 14:30:13
【问题描述】:

我有一个运行 Spring Boot 和 Spring Cloud Streams 的小项目,版本为 Greenwich.SR4

到目前为止,我已尝试包含以下依赖项。

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-actuator-autoconfigure</artifactId>
</dependency>

想要有一个基本上返回代码 200 的 /check/health 端点。

我已经相应地修改了配置,这样我就没有无用的健康配置。

management.endpoints.web.base-path=/check
management.endpoint.health.enabled=true
management.health.solr.enabled=false
management.health.elasticsearch.enabled=false

但是,每当我尝试运行 localhost:8080/check/health 时,都会提示 404。会发生什么?

还提到我已经尝试包含我自己的@RestController,但会发生同样的行为。

【问题讨论】:

  • spring-boot-starter-parent你用的是哪个版本的?

标签: spring spring-boot spring-boot-actuator


【解决方案1】:

运行状况检查的 URL 应该是 http://localhost:8080/check/health,而不是 /check/status

【讨论】:

  • 我的错字很大。我的意思是check/health
  • 为我工作。您可以尝试暂时删除 Spring Cloud 依赖项,以查看这是否导致问题?服务器日志中是否有任何错误?
【解决方案2】:

这取决于 Spring-Boot 版本。在 2.0 版本之后,路径名是 ma​​nage,所以你的正确 url 是:http://localhost:8080/check/health

您也可以使用(.yml 版本)进行更改:

management:
  context-path: /manage
  security:
    enabled: false

【讨论】:

    猜你喜欢
    • 2016-06-01
    • 2020-09-15
    • 2019-01-08
    • 1970-01-01
    • 1970-01-01
    • 2016-03-27
    • 2021-05-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多