class path resource [xx] cannot be resolved to absolute file path because it does not reside
发布线上之后出现的问题,查询资源发现是因为代码中直接调用getFIle()造成的问题。
ClassPathResource classPathResource = new ClassPathResource("xxx/xxx.txt");
File outFile = classPathResource.getFile();
我直接新建一个临时文件File来读取这个
// 我命油腻 不油天
File outFile = new File("x.txt");
//通过流写入到FIle对象中
InputStream in= classPathResource.getInputStream();
// 怎么转就比较方便了
// 操作完成之后
if(outFile.exists()){
outFile.delete();
}