I have a Maven project that I use Eclipse to write. I have a hierarchical src/main/resources such that file1.zip is located in a main directory, which file2.zip and file3.zip are located in a sub-directory of file1.zip.
src/main/resources
models/modelA/file1.zip
models/modelA/subdirectory1
file2.zip
models/modelA/subdirectory2
file3.zip
my pom.xml file has this included
<resources>
<resource>
<directory>src/main/resources/models</directory>
<includes>
<include>**/*.zip</include>
</includes>
</resource>
</resources>
I load the resource as
String file1 = "/models/modelA/file1.zip";
String file2 = "/models/modelA/subdirectory1/file2.zip";
String file2 = "/models/modelA/subdirectory1/file3.zip";
InputStream is1 = getClass().getResourceAsStream(file1);
InputStream is2 = getClass().getResourceAsStream(file2);
InputStream is3 = getClass().getResourceAsStream(file3);
When running the program after mvn package, everything is works. But when I try to run this in Eclipse, is2 and is3 are always null.
The src/main/resources are in my class path. How can I get this to run also in Eclipse?
I should mention I have looked at the SO posts enter link description here enter link description here and many others that do not give an answer to the difference between it working with Eclipse and Maven