Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.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
Spring 从另一个jar中的类读取属性文件_Spring_Maven_Junit - Fatal编程技术网

Spring 从另一个jar中的类读取属性文件

Spring 从另一个jar中的类读取属性文件,spring,maven,junit,Spring,Maven,Junit,我有一个包含多个maven子项目的项目。使用Spring、JPA和JUnit +common + WebserviceBindingProvider.java +views +...... +src/main/test/TestClass.java +src/main/test/resources/mocking.properties The "common" project has a class that reads the properties file "m

我有一个包含多个maven子项目的项目。使用Spring、JPA和JUnit

+common
   + WebserviceBindingProvider.java  
+views
   +......
   +src/main/test/TestClass.java
   +src/main/test/resources/mocking.properties

The "common" project has a class that reads the properties file "mocking.properties" that is in the "views" project test folders - src/main/test/resources/
The common.jar is added as dependency to the views project.

The code is something like below.

Resource resource = new ClassPathResource("/mock_endpoints.properties"); 
props = PropertiesLoaderUtils.loadProperties(resource);
当我运行测试用例时,我得到的“props”为null


有人能告诉我我缺少什么吗。

你的
TestClass.java
应该在
src/test/java/
中,你的
mocking.properties
应该在
src/test/resources/