简体   繁体   English

Spring-boot-actuator 暴露 0 个端点

[英]Spring-boot-actuator exposing 0 endpoints

I am trying to expose the /actuator/health endpoint in my spring-boot application, but my log states that zero endpoints are exposed.我正在尝试在我的 spring-boot 应用程序中公开 /actuator/health 端点,但我的日志指出公开了零个端点。 I have seen some documentation that states that the health endpoint is the only endpoint that is enabled by default but it returns 404 for me.我看到一些文档指出健康端点是唯一默认启用的端点,但它为我返回 404。

Log from startup of application:应用程序启动时的日志:

{"@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}

Accessing /actuator also shows that no endpoints are exposed:访问 /actuator 还表明没有暴露端点:

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

I've looked at several other similar posts but none of the fixes provided works for me.我查看了其他几个类似的帖子,但提供的修复都不适用于我。 I do have my own endpoint as well in a @RestController that I thought might be interfering, but commenting it out its Post/Get-mappings did not help either.我在@RestController中也有我自己的端点,我认为这可能会造成干扰,但是将其注释掉它的 Post/Get-mappings 也无济于事。


My pom.xml is as follows:我的 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>

In my application.yaml I have tried the following:在我的 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

Other settings in the application.yaml (like changing the port) works fine, so I know that the application.yaml is at least being used. application.yaml中的其他设置(如更改端口)工作正常,所以我知道 application.yaml 至少正在使用。

Any ideas?有任何想法吗?

Since spring-boot 2x these endpoints are disabled and you need to enable them.由于 spring-boot 2x 这些端点被禁用,您需要启用它们。 You can try adding the following to your properties:您可以尝试将以下内容添加到您的属性中:

endpoints:
  enabled: false
  health:
    enabled: true

I also tried it via我也试过了

management:
  endpoint:
    health:
      enabled: true

but that didn't work on the platform where I deployed it (WebLogic)但这在我部署它的平台上不起作用(WebLogic)

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

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