1 回答

TA貢獻1895條經驗 獲得超3個贊
在我看來,這就像一個 Spring 錯誤。從來源:
ProtectionDomain protectionDomain = getClass().getProtectionDomain();
CodeSource codeSource = protectionDomain.getCodeSource();
URI location = (codeSource != null) ? codeSource.getLocation().toURI() : null;
String path = (location != null) ? location.getSchemeSpecificPart() : null;
if (path == null) {
throw new IllegalStateException("Unable to determine code source archive");
}
File root = new File(path);
if (!root.exists()) {
throw new IllegalStateException(
"Unable to determine code source archive from " + root);
}
問題是這一行:
String path = (location != null) ? location.getSchemeSpecificPart() : null;
從URI 文檔:
在最高級別,字符串形式的 URI 引用(以下簡稱“URI”)具有以下語法
[方案:]方案特定部分[#片段]
因此,在 URI 中http://localhost/printpoc.jnlp,特定于方案的部分是//localhost/printpoc.jnlp. 然后 Spring 嘗試將其視為文件名,這當然不存在,這就是為什么您會看到您所看到的異常。
Spring 代碼不正確。它錯誤地假設您可以從任何 URI 中創建文件名。只有file:URI 可以安全地轉換為文件名,這可以通過new File(location)或Paths.get(location)正確完成。
我不確定解決方案是什么。Spring Boot 啟動器似乎假設 .jar 始終是本地文件。我懷疑它是否可以與通過 HTTP 獲得的 .jar 文件一起使用。
添加回答
舉報