本地测试 得到路径是:/C:/Users/xingx/Desktop/beifen/da-sys.jar!/BOOT-INF/classes!/templates/%e8%99%9a%e6%8b%9f%e5%8d%a1.xlsx
死活找不到
this.getClass().getClassLoader().getResource().getPath();此方案不行
改为临时文件存储
InputStream stream = getClass().getClassLoader().getResourceAsStream("/path/s");/
获取临时文件
File file = new File("apiclient_cert.p12"); try { //将读取到的类容存储到临时文件中,后面就可以用这个临时文件访问了 FileUtils.copyInputStreamToFile(stream,file); } catch (IOException e) { e.printStackTrace(); }
测试成功