【问题标题】:spring boot actuator custom endpoint does not allow configurable endpoint ID. Example: @Endpoint(id = "${mgmt.id.custom}")spring boot actuator 自定义端点不允许可配置的端点 ID。示例:@Endpoint(id = "${mgmt.id.custom}")
【发布时间】:2019-05-02 16:05:30
【问题描述】:

spring boot actuator 自定义端点不允许配置端点。示例:@Endpoint("${mgmt.id.custom}")。有没有办法从属性文件中获取端点 ID 并将其设置在 @Endpoint(id = "Configured From Property file") 注释中。

【问题讨论】:

    标签: spring-boot spring-boot-actuator


    【解决方案1】:

    https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html#boot-features-external-config-vs-value

    最后,虽然您可以在@Value 中编写 SpEL 表达式,例如 表达式不会从应用程序属性文件中处理。

    所以我认为你做不到。但是,我记得我做过类似的事情

    a.b=1 
    a.b.id=${a.b}
    

    之前,它工作。所以可能你可以这样做。

    您可以 1) 从类的常量变量中注入值,然后 2) 在 Endpoint 注释的 SpringEL 中使用该常量变量(带有 static final 关键字)。

    【讨论】:

      猜你喜欢
      • 2021-04-24
      • 1970-01-01
      • 2015-02-22
      • 2023-03-10
      • 1970-01-01
      • 1970-01-01
      • 2020-06-01
      • 2020-04-19
      • 2015-11-15
      相关资源
      最近更新 更多