Skip to content

Commit 14babb7

Browse files
committed
Clarify environment property precedence rules
Issue: SPR-13845 (cherry picked from commit ebad8db)
1 parent 4fc6ead commit 14babb7

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/asciidoc/core-beans.adoc

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7480,7 +7480,7 @@ is populated with additional default property sources including servlet config a
74807480
context parameters. {api-spring-framework}/web/portlet/context/StandardPortletEnvironment.html[`StandardPortletEnvironment`]
74817481
similarly has access to portlet config and portlet context parameters as property sources.
74827482
Both can optionally enable a {api-spring-framework}/jndi/JndiPropertySource.html[`JndiPropertySource`].
7483-
See Javadoc for details.
7483+
See the javadocs for details.
74847484
====
74857485

74867486
Concretely, when using the `StandardEnvironment`, the call to `env.containsProperty("foo")`
@@ -7492,7 +7492,16 @@ runtime.
74927492
The search performed is hierarchical. By default, system properties have precedence over
74937493
environment variables, so if the `foo` property happens to be set in both places during
74947494
a call to `env.getProperty("foo")`, the system property value will 'win' and be returned
7495-
preferentially over the environment variable.
7495+
preferentially over the environment variable. Note that property values will not get merged
7496+
but rather completely overridden by a preceding entry.
7497+
7498+
For a common `StandardServletEnvironment`, the full hierarchy looks as follows, with the
7499+
highest-precedence entries at the top:
7500+
* ServletConfig parameters (if applicable, e.g. in case of a `DispatcherServlet` context)
7501+
* ServletContext parameters (web.xml context-param entries)
7502+
* JNDI environment variables ("java:comp/env/" entries)
7503+
* JVM system properties ("-D" command-line arguments)
7504+
* JVM system environment (operating system environment variables)
74967505
====
74977506

74987507
Most importantly, the entire mechanism is configurable. Perhaps you have a custom source

0 commit comments

Comments
 (0)