项目报 ClassDefFoundError: org/apache/http/ssl/SSLContexts 错误的解决办法(亲测)

我的代码:

HttpGet httpGet = new HttpGet("https://xxxxxxxxxx");
//设置请求器的配置
HttpClient httpClient = HttpClients.createDefault();
HttpResponse res = httpClient.execute(httpGet);
HttpEntity entity = res.getEntity();
String result = EntityUtils.toString(entity, "UTF-8");
response.getWriter().append(result);

调用HttpClients报错:
项目报 ClassDefFoundError: org/apache/http/ssl/SSLContexts 错误的解决办法(亲测)_第1张图片
报错jar包为:


        org.apache.httpcomponents
        httpclient
        4.5.5

        

        org.apache.httpcomponents
        httpcore
        4.3.2

解决方法:
换高版本的jar包,如下:


        org.apache.httpcomponents
        httpclient
        4.5.5

        

        org.apache.httpcomponents
        httpcore
        4.3.2

重新运行项目后,执行方法不报错,完美解决!

你可能感兴趣的:(开发--报错解决)