报错内容:class path resource [client.p12] cannot be resolved to absolute file path because it does not reside in the file system
问题所在:
代码使用了 File("classpath:client.p12")访问文件 ,这个方法只能从类路径下获取文件,无法从jar包中获取,所以打成jar包后发布到windows系统,就报错找不到文件了.
解决方案
ClassPathResource classPathResource = new ClassPathResource("client.p12]"); 来获取文件,这个方法可以直接从jar包中抓取文件
注:使用类加载器不会对classpath做处理,因此使用类加载器读取文件,路径中不要添加classpath
转载于:.html
本文发布于:2024-02-04 06:47:00,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170701397253303.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |