I have a Spring Web Application which was created as a maven artifact A.war. It has a maven dependency with a artifact B.jar. The src/main/resources of artifact B has a file test.txt. I want to read the file test.txt from artifact A.war. When i explode the B.jar, i see that the test.txt is located in the root of the jar. The B.jar ends up in WEB-INF/lib of the exploded A.war In A, i try to read the file using File f = new ClassPathResource("test.txt").getFile();
I am getting java.io.FileNotFoundException: class path resource [test.txt] cannot be resolved to absolute file path because it does not reside in the file system: jar:B.jar!/test.txt. I also tried File f = new File(getClass().getResource("test.txt").toURI());
Could someone please help?