Spring 从另一个jar中的类读取属性文件
我有一个包含多个maven子项目的项目。使用Spring、JPA和JUnitSpring 从另一个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
+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/
中