tags:

views:

37

answers:

2

Is there a way to reference a properties file on a file system (not on a classpath) relative to the Spring's context file itself?

What I want to do is the below:

<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="locations">
        <list>
            <!-- I want the below to be relative to this context XML file. -->
            <value>app.properties</value>
        </list>
    </property>
</bean>

I was imagining something like ${contextpath} that I could prepend to the above "app.properties" but couldn't find anything helpful.

Thanks.

A: 

You can reference properties on the classpath via the classpath: prefix:

<value>classpath:app.properties</value>
Bozho
Thanks Bohzo. Do you know anyway of specifying a "file path" relative to the context file instead of a classpath?
Daisuke Shimamoto
A: 

why didn't you put the path on the properties file and get it with your spring application.

It is the same right? you can dynamically change your properties file content value.

Yudhi Karunia Surtan