ikvenu2000
ikvenu2000

Reputation: 341

Reading properties file from a class which is in another jar

I have a project with multiple maven subprojects. Using 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);

When i run the test case i am getting the "props" as null.

Can anyone let me know what i am missing.

Upvotes: 0

Views: 147

Answers (1)

maba
maba

Reputation: 48045

Your TestClass.java should be in src/test/java/ and your mocking.properties should be in src/test/resources/.

Upvotes: 1

Related Questions