sslcontextbuilder 和 SSLContexts 已弃用

2022-09-01 20:40:19

我正在使用JDK1.8和JDK编译JavaSE-1.7,Eclipse Luna和Apache httpclient 4.4.1。

我在Eclipse中收到警告,并且已被弃用。这些类有哪些替代方法?sslcontextbuilderSSLContexts


答案 1

实际上,我刚刚一直在研究这个问题,似乎HttpCLient SSLContexts类正在从org.apache.http.conn.ssl.SSLContexts移动到org.apache.http.ssl.SSLContexts。我将导入更改为这些新包,现在看起来很好。不确定你对sslcontextbuilder的引用是什么,但我非常确定它也有一个替代的实现。让我知道更多细节,我可以检查。


答案 2

您可以按照以下代码进行更改

// Fixing deprecated code to use current HttpClient implementations      Sekito.Lv 01/30/2019 11:29     Start
import org.apache.http.ssl.SSLContexts;
import org.apache.http.ssl.SSLContextBuilder;

//import org.apache.http.conn.ssl.SSLContexts;
//import org.apache.http.conn.ssl.SSLContextBuilder;
// Fixing deprecated code to use current HttpClient implementations      Sekito.Lv 01/30/2019 11:29     End