[英]Custom PropertySource in Springboot prevents some properties from loading
我在春季启动中定义了自定义PropertySource
,该属性执行属性解密。 当我在应用程序代码中请求属性值时,一切工作正常,但是我注意到框架使用/加载了一些属性。 (我记录了通过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扩展了EnumerablePropertySource<Properties>
一切都会按预期进行。
这是为什么 ? 为什么我必须扩展EnumerablePropertySource?
Spring Boot在绑定配置时使用DataBinder
。 DataBinder
需要PropertyValues
实现作为要绑定的属性的源。 PropertyValues
合同的一部分是提供对所有已知属性值的访问。 适配器, PropertySourcesPropertyValues
用于公开应用程序的所有的PropertySource
S作为PropertyValues
实现。 如果您的自定义PropertySource
不是EnumerablePropertySource
则适配器无法访问其所有属性,因此不包含它们。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.