简体   繁体   中英

Custom PropertySource in Springboot prevents some properties from loading

I defined custom PropertySource in spring boot, that performs decryption of properties. Everything works fine when I request property values in my application code, however I noticed that some properties that are used/loaded by the framework. ( I log every property that is requested via PropertySource)

ie following are not loaded:

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

I noticed though, that if my PropertySource extednds EnumerablePropertySource<Properties> everything works as expected.

Why is that ? Why do I have to extend EnumerablePropertySource ?

Spring Boot uses a DataBinder when it's 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 is used to expose all of your application's PropertySource s as a PropertyValues implementation. If your custom PropertySource isn't an EnumerablePropertySource then the adapter's unable to access of all of its properties so they aren't included.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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