Spring boot文件读取错误无法解析为绝对文件路径,因为它不在文件系统中: jar: file:
// Gets the XML file under src/main/resources folder
Resource sourceFile = new ClassPathResource("jrxml/report.jrxml");
String jrxmlFilePath = sourceFile.getFile().getPath();需求1. 1.Spring boot项目jar文件2.文件读取3.文件上传
发布于 2018-11-30 11:16:52
如果文件在resources文件夹中,则使用,
Resource sourceFile = new ClassPathResource("report.jrxml");发布于 2018-11-30 11:46:32
尝试使用getResouceAsStream()读取资源文件夹下的文件。
ClassLoader classLoader = getClass().getClassLoader();
InputStreamReader in = null;
try {
in = new InputStreamReader(classLoader.getResourceAsStream("jrxml/report.jrxml"));
...
} catch (...) {
} finally {
...
}https://stackoverflow.com/questions/53550667
复制相似问题