我得到的堆栈跟踪是这样的。
[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);
最佳答案
在我看来,您要么缺少某个库,要么您的类路径中的库版本有误。我怀疑 httpcore 和/或 httpmime 库。
关于java - Apache HTTPClient 没有这样的方法 ContentType.create,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35010543/