英文:
How to solve java.lang.UnsupportedOperationException: clientBuilder.sslSocketFactory(SSLSocketFactory) not supported on JDK 9+?
问题
以下是翻译好的部分:
我每次尝试运行项目时都会出现以下错误。我已将项目的SDK设置为Java 8,尝试过Open JDK和Oracle JDK,但仍然会出现以下错误。我之前曾与该项目一起工作,并且没有任何问题,但是在我的新电脑上无法运行。在这台机器上,我之前安装了Java 11,但我已将其删除。我正在使用一台Mac电脑。
是否有人知道我为什么会出现这个错误?
提前谢谢您。
Caused by: org.springframework.beans.factory.BeanCreationException: 在类路径资源[com/vocalink/bps/reporting/config/RestTemplateConfig.class]中定义的名为'getClientHttpRequestFactory'的bean创建失败:通过工厂方法进行的bean实例化失败;嵌套异常是org.springframework.beans.BeanInstantiationException:工厂方法'getClientHttpRequestFactory'抛出异常;嵌套异常是java.lang.UnsupportedOperationException:JDK 9+不支持clientBuilder.sslSocketFactory(SSLSocketFactory)
英文:
I get the error below every time I try to run a project. I did set the Project SDK to java 8, tried open jdk as well as oracle jdk, but still I get the error below. I worked with this project before and had no problems, but it does not run on my new computer. On this machine I had java 11 installed before, but I deleted it. I am using a mac.
Does anyone know why I get this error?
Thank You in Advance.
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'getClientHttpRequestFactory' defined in class path resource [com/vocalink/bps/reporting/config/RestTemplateConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.http.client.ClientHttpRequestFactory]: Factory method 'getClientHttpRequestFactory' threw exception; nested exception is java.lang.UnsupportedOperationException: clientBuilder.sslSocketFactory(SSLSocketFactory) not supported on JDK 9+
答案1
得分: 1
问题出在 JDK 版本。
有两个解决方案:
- 更新 okhttp 版本;
- 使用较旧的 JDK(使用了 1.8.0_202 版本,可以正常工作)。
英文:
The problem is in the jdk version.
There are 2 solutions to this problem:
- update okhttp version;
- use an older jdk (used 1.8.0_202 and it worked).
答案2
得分: 1
这与此处的回答相同:https://stackoverflow.com/a/63792370/1542667
您正在使用一个长时间不推荐的方法,无法在多个JVM版本范围内得到干净的支持。
英文:
It's the same answer as here https://stackoverflow.com/a/63792370/1542667
You are using a long deprecated method that can't be cleanly supported across a range of JVM versions.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论