![](/img/trans.png)
[英]Using actual properties file from src/main/resources with Spring @PropertySource in JUnit test
[英]Spring JUnit Test load properties of file outside of src/test/resources
我想将一个属性文件加载到 Spring 中,但 Spring 找不到带有此 XML 的属性文件。
该文件位于/MyProject/MyModule/testData/testProperties.properties
测试位于/MyProject/MyModule/src/test/MyTest.java
如何从正确的路径加载弹簧?
<bean id="properties" class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer">
<property name="locations">
<list>
<value>testData/testProperties.properties</value>
</list>
</property>
</bean>
您可以尝试使用file:
前缀
<value>file:/MyProject/MyModule/testData/testProperties.properties</value>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.