我在春季启动应用程序的application.yml文件中提供了以下内容
file.path: classpath:input.txt
我已将input.txt放在src / main / resources下
当我在Docker中部署应用程序时,出现以下异常
Caused by: java.io.FileNotFoundException: class path resource [input.txt] cannot be resolved to absolute file path because it does not reside in the file system: jar:file:/app/app.jar!/BOOT-INF/classes!/input.txt
但是当我从本地运行它时,文件正在加载。请提出一种解决方法。
File rese = new ClassPathResource("input.txt").getFile();
String contents = new String(Files.readAllBytes(res.toPath()));