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

Ret*_*ach 3 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)
Run Code Online (Sandbox Code Playgroud)

触发的线是这个.

response = client.execute(httpPost);
Run Code Online (Sandbox Code Playgroud)

Jul*_*ron 7

在我看来你要么错过了一个库,要么你的类路径上有一个错误的库版本.我怀疑httpcore和/或httpmime库.

  • 降级到httpmime 4.3.6并且它有效 (7认同)