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.

  1. property files
  2. servletconfig init params (
  3. servletcontext init params
  4. jndi
  5. system properties (specified -d)
  6. environment properties

so in case ${my.property} resolve myvaluethree. if preserve defaults. if specify local-override="true" property files consulted last , value myvaluetwo.

links

  • standardservletenvironment javadoc
  • standardenvironment javadoc
  • propertysourcesplaceholderconfigurer javadoc

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -