![](/img/trans.png)
[英]Spring 5.1 + Tomcat 9 + Java 10 + moduled project = java.lang.NoClassDefFoundError: org/springframework/core/io/Resource
[英]spring org.springframework.core.io.UrlResource not support https resource
當配置grails的配置位置如下
grails.config.locations = [
"https://ip:8443/config/Config.groovy"
]
將在日志中獲得以下警告消息
2018-11-28 19:04:22,682 WARN ConfigurationHelper - Unable to load specified config location https://ip:8443/config/Config.groovy : File does not exist.
但我可以直接從瀏覽器訪問https:// ip:8443 / config / Config.groovy 。
在org.codehaus.groovy.grails.commons.cfg.ConfigurationHelper.mergeInLocations()中
private static void mergeInLocations(ConfigObject config, List locations, PathMatchingResourcePatternResolver resolver, ClassLoader classLoader) {
...
def resource = resolver.getResource(location.toString())
if(resource.exists()) {
...
} else {
LOG.warn "Unable to load specified config location $location : File does not exist."
}
}
解析器是春季的org.springframework.core.io.support.PathMatchingResourcePatternResolver 。 和resolver.getResource(location.toString())結果將是org.springframework.core.io.UrlResource
和UrlResource.exists()代碼就像
public boolean exists() {
...
try {
URLConnection con = url.openConnection();
HttpURLConnection httpCon =
(con instanceof HttpURLConnection ? (HttpURLConnection) con : null);
if (httpCon != null) {
int code = httpCon.getResponseCode();
if (code == HttpURLConnection.HTTP_OK) {
return true;
}
else if (code == HttpURLConnection.HTTP_NOT_FOUND) {
return false;
}
}
}catch(IOException ex){
return false;
}
}
自從其https以來,它將拋出java.security.cert.CertificateException: httpCon.getResponseCode()時不存在使用者替代名稱 。
所以UrlResource不是https資源嗎? 如果要加載https資源,該怎么辦? 謝謝。
請注意您描述的錯誤消息,我也可以重復該錯誤消息:“不存在使用者替代名稱”表示您的主機名“ ip”不在證書中。 嘗試切換到完全限定的域名,例如“ ip.mydomain.com”或證書中編碼的任何名稱。 (您可以在瀏覽器的“頁面信息”對話框上查看證書的詳細信息)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.