项目部署在linux服务器上,springboot读取resource下面的文件出现了问题:
cannot be resolved to absolute file path because it does not reside in the file system
可以通过以下方式读取文件内容。
ClassPathResource classPathResource = new ClassPathResource(”/path/to/file“);
InputStream ins = classPathResource.getInputStream();
原因:在服务器上,文件是以流的方式进行读取,所以要通过InputStram读取文件内容。
问题解决,祝好!