首页 新闻 会员 周边 捐助

发送http请求报错:java.lang.NoSuchMethodError: org.apache.http.util.Args.containsNoBlanks

0
[已关闭问题] 关闭于 2018-10-25 18:36

项目以前使用的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]

此生误解的主页 此生误解 | 菜鸟二级 | 园豆:206
提问于:2018-10-25 18:35
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册