java - Precedence of properties: system vs. deployment descriptor vs. properties file -
if have system property pass container (e.g. tomcat) following:
-dmy.property=myvalueone
and property same key defined in web.xml:
<context-param> <param-name>my.property</param-name> <param-value>myvaluetwo</param-value> </context-param>
... , property same key defined in 1 of config*.properties files:
my.property=myvaluethree
which value property have? myvalueone
, myvaluetwo
or myvaluethree
?
if have several properties same key, there hierarchy defines kind of property overwrites other kind of property?
simply said 3 available , can use spel obtain value of each.
#{systemproperties['my.property']} // myvalueone #{servletcontextinitparams['my.property'] // myvaluetwo
the properties depend on how loading them (a @propertysource
or `
however want know happens if use placeholder , have situation have.
<property name="myproperty" value="${my.property}" />
assuming use default (and on spring 3.1 or up) following resources consulted in order, in web based environment.
- property files
- servletconfig init params (
- servletcontext init params
- jndi
- system properties (specified -d)
- environment properties
so in case ${my.property}
resolve myvaluethree. if preserve defaults. if specify local-override="true"
property files consulted last , value myvaluetwo.
links
Comments
Post a Comment