I am trying to read a text file using the Spring Resource Loader as follows:
Resource resource = resourceLoader.getResource("classpath:\\static\\Sample.txt");
The file is here in my Spring boot project:
It works fine when running the application in eclipse, but when I package the application, run it using java -jar, I get a file exception not found:
java.io.FileNotFoundException: class path resource [static/Sample.txt] cannot be resolved to absolute file path because it does not reside in the file system: jar:file:/C:/workspace-test/XXX/target/XXX-0.0.1-SNAPSHOT.jar!/BOOT-INF/classes!/static/Sample.txt
I unzipped the Jar file that contains the Sample: XXX-0.0.1-SNAPSHOT \ BOOT-INF \ classes \ static \ Sample.txt
Can anybody help me?
Thanks in advance!
source share