【发布时间】: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
spring boot actuator 自定义端点不允许配置端点。示例:@Endpoint("${mgmt.id.custom}")。有没有办法从属性文件中获取端点 ID 并将其设置在 @Endpoint(id = "Configured From Property file") 注释中。
【问题讨论】:
标签: spring-boot spring-boot-actuator
说
最后,虽然您可以在@Value 中编写 SpEL 表达式,例如 表达式不会从应用程序属性文件中处理。
所以我认为你做不到。但是,我记得我做过类似的事情
a.b=1
a.b.id=${a.b}
之前,它工作。所以可能你可以这样做。
您可以 1) 从类的常量变量中注入值,然后 2) 在 Endpoint 注释的 SpringEL 中使用该常量变量(带有 static final 关键字)。
【讨论】: