httpclient jar冲突。如何解决?

【字号: 日期:2024-02-28浏览:38作者:雯心
如何解决httpclient jar冲突。如何解决??

该SSLContexts班已搬迁到另一个包中的HttpClient 4.4。

从4.4开始

将您的httpcore版本升级到至少4.4即可解决该问题。

解决方法

//这是我的代码,我正在代理工作…

import org.apache.commons.io.IOUtils;import org.apache.http.HttpHost;import org.apache.http.HttpResponse;import org.apache.http.client.HttpClient;import org.apache.http.client.methods.HttpGet;import org.apache.http.impl.client.DefaultHttpClient;import org.apache.http.impl.client.HttpClients;import org.apache.http.impl.conn.DefaultProxyRoutePlanner;{HttpHost proxy = new HttpHost('proxyhost',8082); DefaultProxyRoutePlanner routePlanner = new DefaultProxyRoutePlanner(proxy);HttpClient client = HttpClients.custom().setRoutePlanner(routePlanner).build();HttpResponse response = client.execute(request);}

//以下错误出现在我的控制台上

Exception in thread 'main' java.lang.NoClassDefFoundError: org/apache/http/ssl/SSLContexts at org.apache.http.impl.client.HttpClientBuilder.build(HttpClientBuilder.java:966) at TwitterFeeds.main(TwitterFeeds.java:40) Caused by: java.lang.ClassNotFoundException: org.apache.http.ssl.SSLContexts at java.net.URLClassLoader$1.run(Unknown Source) at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) ... 2 more

我正在使用以下罐子

httpclient-4.5.2.jarhttpcore-4.3.jar

相关文章: