Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java JUnit测试可以';在类路径上找不到属性文件_Java_Spring_Junit_Properties_Classpath - Fatal编程技术网

Java JUnit测试可以';在类路径上找不到属性文件

Java JUnit测试可以';在类路径上找不到属性文件,java,spring,junit,properties,classpath,Java,Spring,Junit,Properties,Classpath,我的类路径上有一个apiKey.properties文件,该文件在Spring安全上下文中的Spring应用程序中使用。位置定义如下: <beans:property name="apiKeyFileLocation" value="classpath:META-INF/config/apiKey.properties" /> 我尝试了几个类路径的变体,但没有成功。如何从单元测试中获取此属性文件?尝试将属性文件放置在src/test/resources中,而不是src/main/r

我的类路径上有一个apiKey.properties文件,该文件在Spring安全上下文中的Spring应用程序中使用。位置定义如下:

<beans:property name="apiKeyFileLocation" value="classpath:META-INF/config/apiKey.properties" />

我尝试了几个类路径的变体,但没有成功。如何从单元测试中获取此属性文件?

尝试将属性文件放置在
src/test/resources
中,而不是
src/main/resources
。我忘了提到它,但我已经尝试过了,结果相同。
apiKeyPropertiesPath
!=<代码>apiKeyFileLocation。请发布完整的stacktrace。将属性放在src/test/resources下确实有帮助,但这也是代码的重复。
<property name="apiKeyPropertiesPath" value="classpath:META-INF/config/apiKey.properties"/>
java.lang.IllegalArgumentException: Unable to read properties from specified apiKeyFileLocation [classpath:META-INF/config/apiKey.properties].
Caused by: java.io.FileNotFoundException: classpath:META-INF\config\apiKey.properties (The filename, directory name, or volume label syntax is incorrect)