You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In spring boot 2.x i think localProperties loaded through PropertySourcesPlaceholderConfigurer are getting more preference over cloud config server properties with localOverride flag as false(by default).
Working fine in spring boot version 1.5.x.
To reproduce the issue:
Create a cloud config server having some property let say spring.sample-property=sample property server
Now create a local properties file local-config.properties having same property spring.sample-property=sample property client and load it through PropertySourcesPlaceholderConfigurer.
Intialize POJO class through @ConfigurationProperties
It will load value as "sample property client" from local properties file rather than from cloud config server.
I am attaching a sample project that will demonstrate the above steps.
Zip file contains 3 projects -
config-server which contains cloud config server
configClient-1.5.14.RELEASE which contains spring boot application with version 1.5.14.RELEASE
configClient-2.0.3.RELEASE which contains spring boot application with version 1.5.14.RELEASE
Run config-server it will contains the cloud config property with property spring.sample-property=sample property server
Run configClient-1.5.14.RELEASE it contains local property file(local-config.properties) with property spring.sample-property=sample property client
Run configClient-2.0.3.RELEASE it contains local property file(local-config.properties) with property spring.sample-property=sample property client
Now after running the clients these are the value that is bind to SpringProperty POJO class -
For configClient-1.5.14.RELEASE - sampleProperty = sample property server(Correct behaviour)
For configClient-2.0.3.RELEASE - sampleProperty = sample property client
Output could be checked in log file(search for sample-property ------) or could be accessed through rest controller.
I triaged the issue and could see that in PropertySourcesDeducer following snippet where there is filtering on enviromentProperties. Hence localProperties take more preference over enviromentProperties whether localOverride flag is true or not.
vtiwari2134
changed the title
localProperties are getting more preference over environmentProperties in spring boot 2.x
localProperties get more preference over environmentProperties in spring boot 2.x
Jul 10, 2018
Hi,
In spring boot 2.x i think localProperties loaded through
PropertySourcesPlaceholderConfigurer
are getting more preference over cloud config server properties withlocalOverride
flag as false(by default).Working fine in spring boot version 1.5.x.
To reproduce the issue:
spring.sample-property=sample property server
local-config.properties
having same propertyspring.sample-property=sample property client
and load it throughPropertySourcesPlaceholderConfigurer
.@ConfigurationProperties
I am attaching a sample project that will demonstrate the above steps.
Run config-server it will contains the cloud config property with property
spring.sample-property=sample property server
Run configClient-1.5.14.RELEASE it contains local property file(local-config.properties) with property
spring.sample-property=sample property client
Run configClient-2.0.3.RELEASE it contains local property file(local-config.properties) with property
spring.sample-property=sample property client
Now after running the clients these are the value that is bind to SpringProperty POJO class -
For configClient-1.5.14.RELEASE -
sampleProperty = sample property server
(Correct behaviour)For configClient-2.0.3.RELEASE -
sampleProperty = sample property client
Output could be checked in log file(search for sample-property ------) or could be accessed through rest controller.
I triaged the issue and could see that in
PropertySourcesDeducer
following snippet where there is filtering on enviromentProperties. Hence localProperties take more preference over enviromentProperties whether localOverride flag is true or not.propertiesIssue.zip
The text was updated successfully, but these errors were encountered: