I have a simple Maven project where in one of my test, I would like to load a resource as a csv file from the resources folder. The resources folder is made available under src/test/resources
When I run the following code snippet:
URL url = getClass()
.getClassLoader()
.getResource("/myData.csv");
System.out.println(this.getClass().getResource("."));
System.out.print(url); // this gives null
I get a null for the url! Here is my build file:
<build>
<resources>
<resource>
<directory>src/test/resources</directory>
<includes>
<include>*.csv</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>${target.jdk}</source>
<target>${target.jdk}</target>
</configuration>
</plugin>
</plugins>
</build>
Why is this not working? I'm on IntelliJ!