Apache HTTPClient没有这样的方法ContentType.create

时间:2016-01-26 09:26:55

标签: java apache httpclient

我正在获得的堆栈跟踪就是这个。

[04:18:36 WARN]: java.lang.NoSuchMethodError: org.apache.http.entity.ContentType.create(Ljava/lang/String;[Lorg/apache/http/NameValuePair;)Lorg/apache/http/entity/ContentType;
[04:18:36 WARN]:        at org.apache.http.entity.mime.MultipartEntityBuilder.buildEntity(MultipartEntityBuilder.java:219)
[04:18:36 WARN]:        at org.apache.http.entity.mime.MultipartEntity.getEntity(MultipartEntity.java:119)
[04:18:36 WARN]:        at org.apache.http.entity.mime.MultipartEntity.isChunked(MultipartEntity.java:138)
[04:18:36 WARN]:        at org.apache.http.protocol.RequestContent.process(RequestContent.java:105)
[04:18:36 WARN]:        at org.apache.http.protocol.ImmutableHttpProcessor.process(ImmutableHttpProcessor.java:131)
[04:18:36 WARN]:        at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:193)
[04:18:36 WARN]:        at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:86)
[04:18:36 WARN]:        at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:108)

此触发的行就是这个。

response = client.execute(httpPost);

1 个答案:

答案 0 :(得分:5)

让我觉得你错过了一个图书馆,或者你的类路径上有一个错误版本的库。我怀疑是httpcore和/或httpmime库。