Reputation: 16669
Calling
getClass().getResource("./");
// or
getClass().getClassLoader().getResource("./");
from within my JUnit test has different results when executed in Eclipse and IntelliJ IDEA:
C:/project/war/WEB-INF/classes/
C:/project/src/test/resources/
All settings appear to be equal:
C:/project/war/WEB-INF/classes
.C:/project
src/main/java
, src/main/resources
...)My resources are located under src/main/resources/mypackage
, my JUnit file under src/test/java/mypackage
. When executed in Eclipse, the classloader points to the output directory (which contains both java classes and resources). In IntelliJ it points to the src/test/resources
source folder.
How can I force IntelliJ to use the output directory for my classloader? Alternatively, how can I force it to use the right source folder src/main/resources
where my resources are located?
Upvotes: 1
Views: 1938
Reputation: 850
In Intellij, right click on src/main/resources, then select Mark Directory As -> Resources Root
Upvotes: 2