Spring Boot 中的自定义 PropertySource 阻止加载某些属性

Custom PropertySource in Springboot prevents some properties from loading

我在 spring 引导中定义了自定义 PropertySource,它执行属性解密。当我在我的应用程序代码中请求 属性 值时一切正常,但是我注意到框架的某些属性是 used/loaded。 (我记录了通过 PropertySource 请求的每个 属性)

即以下未加载:

http.mappers.json-pretty-print=true
server.ssl.key-store-type=....
server.ssl.key-store=....
server.ssl.key-store-passsowrd=....
server.ssl.key-password=....

不过我注意到,如果我的 PropertySource extendnds EnumerablePropertySource<Properties> 一切正常。

这是为什么?为什么我必须扩展 EnumerablePropertySource ?

Spring 当 binding configuration. A DataBinder requires a PropertyValues implementation as a source for the properties that are to be bound. Part of the PropertyValues contract is to provide access to all of the known property values. An adapter, PropertySourcesPropertyValues 用于将应用程序的所有 PropertySource 作为 PropertyValues 实现公开时,引导使用 DataBinder。如果您的自定义 PropertySource 不是 EnumerablePropertySource,则适配器无法访问其所有属性,因此不包含它们。