報錯內容:class path resource [client.p12] cannot be resolved to absolute file path because it does not reside in the file system
問題所在:
代碼使用了 ResourceUtils.getFile("classpath:client.p12")訪問文件 ,這個方法只能從類路徑下獲取文件,無法從jar包中獲取,所以打成jar包后發布到windows系統,就報錯找不到文件了.
解決方案
ClassPathResource classPathResource = new ClassPathResource("client.p12]"); 來獲取文件,這個方法可以直接從jar包中抓取文件
注:使用類加載器不會對classpath做處理,因此使用類加載器讀取文件,路徑中不要添加classpath