0
正如所討論的https://stackoverflow.com/a/22632251/379235,我說我的代碼資源文件無法找到
@Value("classpath:lpLogCompressFileLocations")
private Resource logLocations;
,並在我的jar文件使用它作爲
Compressor getCompressor() throws IOException {
System.out.println("logLocationsFileExists:" + logLocations.getFile().exists());
return new Compressor(".", logLocations.getFile(), ZIP_NAME_PREFIX);
}
我可以找到這個文件,以及
$ jar -tvf target/original-Processor.jar | grep lpLog
60 Wed Apr 15 12:19:02 PDT 2015 lpLogCompressFileLocations
但是當我部署此代碼並嘗試訪問時,我得到
15 Apr 2015 12:17:56,530 [DEBUG] [http-bio-8443-exec-3] ReportSender | Error in starting compression: class path resource [lpLogCompressFileLocations] cannot be resolved to absolute file path because it does not reside in the file system: jar:file:/shn/lp/original-LogProcessor.jar!/lpLogCompressFileLocations
我也試圖改變我的代碼
@Value("classpath:/lpLogCompressFileLocations")
private Resource logLocations;
但錯誤是相同
15 Apr 2015 12:19:30,984 [DEBUG] [http-bio-8443-exec-1] ReportSender | Error in starting compression: class path resource [lpLogCompressFileLocations] cannot be resolved to absolute file path because it does not reside in the file system: jar:file:/shn/lp/original-LogProcessor.jar!/lpLogCompressFileLocations
我缺少什麼?