marcinn
marcinn

Reputation: 1786

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)

i.e. 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 ?

Upvotes: 0

Views: 629

Answers (1)

Andy Wilkinson
Andy Wilkinson

Reputation: 116091

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 PropertySources 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.

Upvotes: 4

Related Questions