项目以前使用的httpcore和httpclient 版本都比较低了,我将org.apache.httpcomponents下的httpcore(4.3.2)和httpclient(4.3.5)都换成新的版本(httpcore(4.4.4)和httpclient(4.5.2),结果导致发送http请求时报错.请问这个问题怎么解决呢?
public String postOrder(String xmlStr,String posturl) {
LOGGER.info("posturl:---------------"+posturl);
LOGGER.info("xmlStr:---------------"+xmlStr);
// posturl="https://api.mch.weixin.qq.com/pay/unifiedorder";
HttpPost post = new HttpPost(posturl);
try {
String str = new String(xmlStr.getBytes(), "ISO8859-1");
StringEntity entity = new StringEntity(str);
post.setEntity(entity);
HttpResponse response = client.execute(post);
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
String returnXml = EntityUtils.toString(response.getEntity(), "UTF-8");
LOGGER.info("returnXml:---------------"+returnXml);
return returnXml;
}
} catch (Exception e) {
e.printStackTrace();
}
return "";
}
java.lang.NoSuchMethodError: org.apache.http.util.Args.containsNoBlanks(Ljava/lang/CharSequence;Ljava/lang/String;)Ljava/lang/CharSequence;
at org.apache.http.HttpHost.<init>(HttpHost.java:80) ~[httpcore-4.4.1.jar:4.4.1]
at org.apache.http.client.utils.URIUtils.extractHost(URIUtils.java:383) ~[httpclient-4.5.1.jar:4.5.1]
at org.apache.http.impl.client.CloseableHttpClient.determineTarget(CloseableHttpClient.java:92) ~[httpclient-4.5.1.jar:4.5.1]
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82) ~[httpclient-4.5.1.jar:4.5.1]
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:107) ~[httpclient-4.5.1.jar:4.5.1]
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55) ~[httpclient-4.5.1.jar:4.5.1]