2012-10-25 47 views
0

我有一個包含多個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); 

當我運行測試用例時,我得到的「道具」爲null。

任何人都可以讓我知道我錯過了什麼。

回答

1

您的TestClass.java應該在src/test/java/和您的mocking.properties應該在src/test/resources/

相關問題