Reputation: 8746
I am trying to use PropertySourcesPlaceholderConfigurer
. However, I am confused by the concepts of "local property" and "environment property", as in the Spring API javadoc:
Search precedence of local properties is based on the value of the localOverride property, which is by default false meaning that local properties are to be searched last, after all environment property sources.
For example, what is a local property? What is an environment property? How are they defined in code? What is the rationale behind the separation of the two?
Thank you very much.
Upvotes: 2
Views: 655
Reputation: 279970
Environment properties are properties from the environment :). Those are properties you can get through
System.getenv()
System.getProperties()
Spring registers both of those and makes them available to you.
Local properties are those that you declare with the PropertySourcesPlaceholderConfigurer
.
PropertySourcesPlaceholderConfigurer c = new PropertySourcesPlaceholderConfigurer();
c.setLocation(new ClassPathResource("/some.properties"));
You may want to have properties with the same key in your local properties. You would use the localOverride
to decide which gets precedence. Remember, properties are stored in PropertySource
objects. Spring will iterate through all the registered PropertySource
objects and return the first property it finds for the key you provide.
Upvotes: 4