繁体   English   中英

Springboot中的Custom PropertySource阻止加载某些属性

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM