Anshul
Anshul

Reputation: 645

Load multiple properties file using <util:properties> in spring 3

I want to load multiple properties files using <util:properties> tag in a spring 3 application. I searched on the blogs, but cannot get the correct path to do this.

Hopefully somebody give me the answer to overcome this problem.

Upvotes: 10

Views: 11763

Answers (3)

Alexei Osipov
Alexei Osipov

Reputation: 762

Actually <util:properties> is just convenient tag for org.springframework.beans.factory.config.PropertiesFactoryBean. And PropertiesFactoryBean does support multiple locations.

So it is possible to create bean with Properties this way:

    <bean id="myProps" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
        <property name="locations">
            <list>
                <value>classpath:myprops-common.properties</value>
                <value>classpath:myprops-override.properties</value>
                <value>classpath:some-more-props-here.properties</value>
            </list>
        </property>
    </bean>

Upvotes: 24

Aravind Yarram
Aravind Yarram

Reputation: 80166

util:properties seems to support only 1 properties file (reference). You might want to use the configuration suggested by @peperg.

Upvotes: 3

Piotr Gwiazda
Piotr Gwiazda

Reputation: 12212

My solution

<context:property-placeholder location="classpath*:*.properties,file:/some/other/path/*.properties" />

Upvotes: 10

Related Questions