如何启用执行器中的所有端点(Spring Boot 2.0.0 RC1)

How to enable all endpoints in actuator (Spring Boot 2.0.0 RC1)

我从 1.5.10 移动到 Spring Boot 2.0.0 RC1,并且我一直在使用最新版本的执行器。如何启用公开和启用所有执行器端点?

唯一公开的端点是:

{
  "_links": {
    "self": {
      "href": "http://127.0.0.1:8080/actuator",
      "templated": false
    },
    "health": {
      "href": "http://127.0.0.1:8080/actuator/health",
      "templated": false
    },
    "info": {
      "href": "http://127.0.0.1:8080/actuator/info",
      "templated": false
    }
  }
}

这是我的 application.properties 文件。有什么想法吗?

#The three first ones seem to be obsolete
endpoints.configprops.enabled=true
endpoints.beans.enabled=true
endpoints.shutdown.enabled=true

management.endpoints.enabled-by-default=true
management.endpoints.sensitive=false
management.endpoints.enabled=true

management.endpoint.configprops.enabled=true
management.endpoint.beans.enabled=true
management.endpoint.shutdown.enabled=true

management.endpoints.web.exposure.include=*

使用 Spring Boot 2.0.0.RC1,执行器端点必须 1) 启用和 2) 公开。

默认情况下,启用除 shutdown 之外的所有端点,并且仅公开 healthinfo

对于您的情况,以下应该有效:

management.endpoints.web.expose=*
# if you'd like to expose shutdown:
# management.endpoint.shutdown.enabled=true

请注意,从 Spring Boot 2.0.0.RC2:

开始,这又发生了变化!
management.endpoints.web.exposure.include=*
# if you'd like to expose shutdown:
# management.endpoint.shutdown.enabled=true

有疑问,the dedicated migration guide 总是 up-to-date 具有最新的更改。

编辑

为了便于复制和粘贴,这里是“yaml”版本 - Spring Boot 2.0.0.RC2:

management:
  endpoints:
    web:
      exposure:
        include: "*"

之前:

management:
  endpoints:
    web:
      expose: "*"

我要补充一点,对于 Spring Boot 2,执行器安全性已更改(对于 1.X,执行器的安全性具有单独的配置,当它与用户配置混合时经常会导致问题)。对于 Spring Boot 2.X,执行器将没有单独的安全配置。根据 Spring 文档:

For security purposes, all actuators other than /health and /info are disabled by default. The management.endpoints.web.expose flag can be used to enable the actuators. If Spring Security is on the classpath and no other WebSecurityConfigurerAdapter is present, the actuators are secured by Spring Boot auto-config. If you define a custom WebSecurityConfigurerAdapter, Spring Boot auto-config will back off and you will be in full control of actuator access rules.)