theAnonymous
theAnonymous

Reputation: 1804

Spring JUnit Test load properties of file outside of src/test/resources

I want to load a properties file into Spring,but Spring cannot find the properties file with this XML.

The File is at /MyProject/MyModule/testData/testProperties.properties

The Test is at /MyProject/MyModule/src/test/MyTest.java

How to make Spring load from the correct path?

<bean id="properties" class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer">
    <property name="locations">
        <list>
            <value>testData/testProperties.properties</value>
        </list>
    </property>
</bean>

Upvotes: 0

Views: 95

Answers (1)

Ivan
Ivan

Reputation: 8758

You can try using file: prefix

<value>file:/MyProject/MyModule/testData/testProperties.properties</value>

Upvotes: 1

Related Questions