17

I have got 2 properties file with me. I have mentioned both the files in the context:property-placeholder like this...

<context:property-placeholder location="conf/ConfServer.conf,conf/LicenseSettings.properties" />

Also I have tried this

<context:property-placeholder location="conf/ConfServer.conf,conf/LicenseSettings.properties" />

<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="locations">
        <list>
            <value>conf/LicenseSettings.properties</value>
        </list>
    </property>
   <property name="ignoreUnresolvablePlaceholders" value="true"/>
</bean>

Both the above mentioned methods I have tried are not working.
Can anyone spot out the mistake and help me out of this?
I already referred to this, but it didn't work good for me.

Freakyuser
  • 2,774
  • 17
  • 45
  • 72

2 Answers2

43

You can specify multiple context:property-placeholder tags within your configuration file. You can also specify which will be loaded first using the order attribute.

<context:property-placeholder location="conf/ConfServer.conf" order="1" ignore-unresolvable="true" />
<context:property-placeholder location="conf/LicenseSettings.properties" order="2" ignore-unresolvable="true" />
Kevin Bowersox
  • 93,289
  • 19
  • 159
  • 189
  • 1
    Thank you very much. On trying this, the result is same. The `conf/ConfServer.conf` is working good but not the 2nd file. Do you want me to post the code, I am using to initialize the variables read from the file? – Freakyuser Jan 22 '13 at 10:48
  • Sorry I was wrong, your method worked good. Thank you very much. It took me around 2 hours to solve this. Thank you once again. – Freakyuser Jan 22 '13 at 10:52
  • 2
    Using Spring 4.1.5, I only managed to use a single context:property-placeholder tag successfully, however the "location" attribute accepts multiple comma-separated locations. See e.g. http://stackoverflow.com/a/3407752/218139 – Stefan L Mar 10 '15 at 15:52
  • I had the same issue and ignore-unresolvable="true" fixed my problem. – Korobko Alex Aug 10 '15 at 21:15
  • Can I have two property file , one is for prod , one for dev? – JaskeyLam Mar 03 '16 at 12:15
1

Can you try referring these properties from project root directory

conf/ConfServer.conf

conf/LicenseSettings.properties

These may not be referred correctly.

Jon Raynor
  • 3,804
  • 6
  • 29
  • 43
brownfox
  • 557
  • 8
  • 14