How to solve java.lang.UnsupportedOperationException: clientBuilder.sslSocketFactory(SSLSocketFactory) not supported on JDK 9+?

huangapple go评论84阅读模式
英文:

How to solve java.lang.UnsupportedOperationException: clientBuilder.sslSocketFactory(SSLSocketFactory) not supported on JDK 9+?

问题

以下是翻译好的部分:

我每次尝试运行项目时都会出现以下错误。我已将项目的SDK设置为Java 8,尝试过Open JDK和Oracle JDK,但仍然会出现以下错误。我之前曾与该项目一起工作,并且没有任何问题,但是在我的新电脑上无法运行。在这台机器上,我之前安装了Java 11,但我已将其删除。我正在使用一台Mac电脑。

是否有人知道我为什么会出现这个错误?

提前谢谢您。

How to solve java.lang.UnsupportedOperationException: clientBuilder.sslSocketFactory(SSLSocketFactory) not supported on JDK 9+?

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.

How to solve java.lang.UnsupportedOperationException: clientBuilder.sslSocketFactory(SSLSocketFactory) not supported on JDK 9+?

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 版本。
有两个解决方案:

  1. 更新 okhttp 版本;
  2. 使用较旧的 JDK(使用了 1.8.0_202 版本,可以正常工作)。
英文:

The problem is in the jdk version.
There are 2 solutions to this problem:

  1. update okhttp version;
  2. 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.

huangapple
  • 本文由 发表于 2020年9月9日 18:20:35
  • 转载请务必保留本文链接:https://go.coder-hub.com/63809600.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定