Spring Boot Actuator configprops 端点未返回 @Value 注释属性
Spring Boot Actuator configprops endpoint not returning @Value annotated properties
我正在为我们的 IT 团队编写一个中央控制台,以显示从 Spring Boot Actuator 端点 /configprops 为我们的 SOA 生态系统中的每个微服务 运行 检索的属性。我有 2 个问题
- 尽管文档说
,但似乎 @Value 注释属性不会返回
63.7 Discover built-in options for external properties ....
The definitive list comes from searching the source code for @ConfigurationProperties and @Value annotations, as well as the occasional use of RelaxedEnvironment
查看 ConfigurationPropertiesReportEndpoint.java,看起来它只搜索带注释的 @ConfigurationProperties 类:
beans.putAll(context.getBeansWithAnnotation(ConfigurationProperties.class));
- 是否有一种简单的方法可以确定 最终属性 值的解析来源?例如:属性 是否被环境变量覆盖了?或者,它是否来自 git 存储库?
第 63.7 节试图说明发现所有属性(因为它们可以以多种方式绑定)的唯一明确方法是搜索源代码。我们尽量使用 @ConfigurationProperties
,以便它们可以被 IDE 发现并被执行器公开。不幸的是,我们没有办法检测和公开报告中的每一个 属性。
目前没有明确的方法可以判断 属性 来自哪里。您也许可以从 ConfigurableEnvironment
查看 getPropertySources()
。这将让您迭代 PropertySource
项目,然后您可以检查它们是否是 EnumerablePropertySource
并获取值。每个 PropertySource
都有一个 name
,这可能会提供添加它的线索。
我正在为我们的 IT 团队编写一个中央控制台,以显示从 Spring Boot Actuator 端点 /configprops 为我们的 SOA 生态系统中的每个微服务 运行 检索的属性。我有 2 个问题
- 尽管文档说 ,但似乎 @Value 注释属性不会返回
63.7 Discover built-in options for external properties .... The definitive list comes from searching the source code for @ConfigurationProperties and @Value annotations, as well as the occasional use of RelaxedEnvironment
查看 ConfigurationPropertiesReportEndpoint.java,看起来它只搜索带注释的 @ConfigurationProperties 类:
beans.putAll(context.getBeansWithAnnotation(ConfigurationProperties.class));
- 是否有一种简单的方法可以确定 最终属性 值的解析来源?例如:属性 是否被环境变量覆盖了?或者,它是否来自 git 存储库?
第 63.7 节试图说明发现所有属性(因为它们可以以多种方式绑定)的唯一明确方法是搜索源代码。我们尽量使用 @ConfigurationProperties
,以便它们可以被 IDE 发现并被执行器公开。不幸的是,我们没有办法检测和公开报告中的每一个 属性。
目前没有明确的方法可以判断 属性 来自哪里。您也许可以从 ConfigurableEnvironment
查看 getPropertySources()
。这将让您迭代 PropertySource
项目,然后您可以检查它们是否是 EnumerablePropertySource
并获取值。每个 PropertySource
都有一个 name
,这可能会提供添加它的线索。