簡體   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