PDA

View Full Version : Multiple configuration files and PropertyPlaceHolder


mlarchet
Feb 16th, 2006, 06:03 AM
Hello,

I'm currently working on my first Portlet with Spring-MVC.
In my web.xml file, I've declared a ContextLoaderListener with context parameter 'contextConfigLocation' pointing at my applicationContext.xml file (which is almost empty except my ViewResolverBean).

In my portlet.xml file, I've configured a DispatcherPortlet with contextConfigLocation pointing at my 3 configuration files, dao.xml, domain.xml and web.xml. There's a PropertyPlaceHolderConfigurer in my dao.xml but properties aren't available in my other files, even if I configure another PropertyPlaceHolderConfigurer in each config file.

I've already tried to declare my PropertyConfigurer il my applicationContext.xml file but it doesn't work either.

Is there any solution, except using only one configuration file ?

Thanks

johnalewis
Mar 23rd, 2006, 10:50 AM
Sorry for being slow to respond to this. I am very delinquent in reviewing the forums. I've set up a similar configuration within the portlet sample app and I am not having any problems. Can you post the relevant entries from your portlet.xml and the context files?

pjydc
Mar 23rd, 2006, 12:18 PM
<bean id="propertyConfigurer2"
class="org.springframework.beans.factory.config.PropertyP laceholderConfigurer">
<property
name="location"><value>classpath:applicationConfig.properties</value></property>

<property
name="placeholderPrefix"><value>#{</value></property>
</bean>

Define one property configurer for your second property file as above and
use #{} to for values defined your property file.

The same trick for more property files.

I am not sure whether it is the best way, but it works for me.
Let us know whether it works for you.

Cheers!