【问题标题】:Spring Actuator does not map to localhost:xxxx/actuatorSpring Actuator 不映射到 localhost:xxxx/actuator
【发布时间】:2021-08-27 23:54:51
【问题描述】:

我有一个 Spring Boot 应用程序,我在 pom.xml 中包含了 Spring Actuator

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

我的配置是这样的

management:
  server:
    port: 8200
  endpoints:
    web:
      exposure:
        include: "*"
  endpoint:
    health:
      show-details: always
    metrics:
      enabled: false
  metrics:
    tags:
      application: ${my.application.name}
  health:
    jms:
      enabled: false

但是,当我尝试使用 localhost:8200/actuator 检查端点时,我的浏览器显示

This site can’t be reached
localhost refused to connect.

在我的 IntelliJ IDEA 中,我可以看到执行器选项卡,它似乎在那里工作,但没有 URL 映射。有人可以帮忙吗?

【问题讨论】:

  • 检查控制台输出或记录Exposing 2 endpoint(s) beneath base path '/actuator'之类的东西。
  • @LMC 我在日志中没有看到这一行。我有另一个服务,它的执行器正在工作,但在它的日志中也找不到这条线。
  • 可能您的日志级别为 ERROR。这是整行27-08-2021 21:00:54.911 [main] INFO o.s.b.a.e.web.EndpointLinksResolver.&lt;init&gt; - Exposing 2 endpoint(s) beneath base path '/actuator'
  • 尝试使用 127.0.0.1:8200 连接

标签: java spring spring-boot spring-actuator


【解决方案1】:

在您的 yml 配置中,您将管理服务器端口设置为 8200 而不是您的应用程序端口。因此,您仍然需要连接到您的应用程序端口(应该是 8080,除非您已将其设置为其他端口)以对您的应用程序进行健康检查。

https://cloud.spring.io/spring-cloud-consul/reference/html/#registering-management-as-a-separate-service

试着这样称呼它:

http://localhost:8080/actuator

或者如果您更改了端口:

http://localhost:{port}/actuator

【讨论】:

  • 谢谢。我试过了,但它也不起作用。
猜你喜欢
  • 1970-01-01
  • 2016-06-01
  • 2020-09-15
  • 1970-01-01
  • 2022-07-08
  • 2019-03-15
  • 2020-04-11
  • 2016-06-19
  • 1970-01-01
相关资源
最近更新 更多