繁体   English   中英

Spring-boot-actuator 暴露 0 个端点

[英]Spring-boot-actuator exposing 0 endpoints

我正在尝试在我的 spring-boot 应用程序中公开 /actuator/health 端点,但我的日志指出公开了零个端点。 我看到一些文档指出健康端点是唯一默认启用的端点,但它为我返回 404。

应用程序启动时的日志:

{"@timestamp":"2022-06-29T09:50:59.441+02:00","@version":1,"message":"Exposing 0 endpoint(s) beneath base path '/actuator'","logger_name":"org.springframework.boot.actuate.endpoint.web.EndpointLinksResolver","thread_name":"main","level":"INFO","level_value":20000,"caller_class_name":"org.springframework.boot.actuate.endpoint.web.EndpointLinksResolver","caller_method_name":"<init>","caller_file_name":"EndpointLinksResolver.java","caller_line_number":58}

访问 /actuator 还表明没有暴露端点:

{"_links":{"self":{"href":"http://localhost:8000/actuator","templated":false}}}

我查看了其他几个类似的帖子,但提供的修复都不适用于我。 我在@RestController中也有我自己的端点,我认为这可能会造成干扰,但是将其注释掉它的 Post/Get-mappings 也无济于事。


我的 pom.xml 如下:

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.6.6</version>
        <relativePath />
</parent>

...

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

在我的 application.yaml 中,我尝试了以下操作:

server:
  port: 8000

management:
  health:
    probes:
      enabled: true
    livenessstate:
      enabled: true
    readinessstate:
      enabled: true

  endpoint:
    health:
      probes:
        enabled: true
      show-details: always
      enabled: true

  endpoints:
    web:
      exposure:
        include: '*'
    enabled-by-default: true

application.yaml中的其他设置(如更改端口)工作正常,所以我知道 application.yaml 至少正在使用。

有任何想法吗?

由于 spring-boot 2x 这些端点被禁用,您需要启用它们。 您可以尝试将以下内容添加到您的属性中:

endpoints:
  enabled: false
  health:
    enabled: true

我也试过了

management:
  endpoint:
    health:
      enabled: true

但这在我部署它的平台上不起作用(WebLogic)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM