Spring :Why can't configure two ServletContextPropertyPlaceholderConfigurer in separated .xml? -


greetings,

i working on spring based web application. situation :

  1. there 2 .xml file 1 application-context.xml , other default-context.xml
  2. application-context.xml load web context when tomcat started ,which configured in web.xml
  3. application-context.xml servletcontextpropertyplaceholderconfigurer loaded properties.and import default-context.xml

    because default-context.xml in project, , want have own .properties(default-context.properties) file , set servletcontextpropertyplaceholderconfigurer load properties.

the current result : properties in default-context.properties not loaded, , servletcontextpropertyplaceholderconfigurer in default-context.xml not inited. reports

can't resolve placeholder xxxxxx"

i tried combinations,

1.to load default-context.properties in application-context.xml 's servletcontextpropertyplaceholderconfigurer ,its worked.

2.to load default-context.properties in application-context.xml 's propertyplaceholderconfigurer ,not work. guess because propertyplaceholderconfigurer can't load servlet context?

3.loading default-context.properties in default-context.xml in both ways (servletcontextpropertyplaceholderconfigurer or propertyplaceholderconfigurer) not work.

i can't figure out why there's 1 servletcontextpropertyplaceholderconfigurer can configured in servlet context?

configuration : in application-context.xml

      <class="org.springframework.web.context.support.servletcontextpropertyplaceholderconfigurer">     <property name="locations">         <list>             <value>classpath:etc/system.properties             </value> 

...

in default-context.xml :

 <bean id="tempname123"     class="org.springframework.web.context.support.servletcontextpropertyplaceholderconfigurer" >     <property name="locations">         <list>            <value>classpath:etc/default-datasource.properties</value>         </list>     </property> </bean> 

you can use different placeholder prefix , suffix second bean. following declaration can use placeholder #[some.property.name].

<bean  class="org.springframework.web.context.support.servletcontextpropertyplaceholderconfigurer" p:location="classpath:etc/default-datasource.properties"  p:placeholderprefix="#[" p:placeholdersuffix="]">     </bean> 

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -