[英]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.