您正在将apache HttpClient 4.3库与apache HttpClient 4.2代码一起使用。
请注意,在您的情况下,getParams()和ConnRoutePNames不是唯一不推荐使用的方法。DefaultHttpClient类本身依赖于4.2实现,并且在4.3中也不推荐使用。
关于此处的4.3文档(http://hc.apache.org/httpcomponents-
client-4.3.x/tutorial/html/connmgmt.html#d5e473),您可以通过以下方式重写它:
private HttpClient createHttpClientOrProxy() { HttpClientBuilder hcBuilder = HttpClients.custom(); // Set HTTP proxy, if specified in system properties if( isSet(System.getProperty("http.proxyHost")) ) { int port = 80; if( isSet(System.getProperty("http.proxyPort")) ) { port = Integer.parseInt(System.getProperty("http.proxyPort")); } HttpHost proxy = new HttpHost(System.getProperty("http.proxyHost"), port, "http"); DefaultProxyRoutePlanner routePlanner = new DefaultProxyRoutePlanner(proxy); hcBuilder.setRoutePlanner(routePlanner); } CloseableHttpClient httpClient = hcBuilder.build(); return httpClient;}


