加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

java.lang.NoClassDefFoundError:org / apache / http / concur

发布时间:2020-12-15 04:44:48 所属栏目:Java 来源:网络整理
导读:我正在尝试使用Unirest-Mashape来构建 java应用程序. 这是我的代码: import com.mashape.unirest.http.*;public class PAskMe{ public static void main(String args[]) throws Exception { HttpResponseJsonNode response = Unirest.get("https://montanaf
我正在尝试使用Unirest-Mashape来构建 java应用程序.

这是我的代码:

import com.mashape.unirest.http.*;
public class PAskMe
{
  public static void main(String args[]) throws Exception
  {
        HttpResponse<JsonNode> response = Unirest.get("https://montanaflynn-dictionary.p.mashape.com/define?word=irony").
                                                                                header("X-Mashape-Key","KEY").
                                                                                asJson();
        System.out.println(response.toString());
  }
}

当我编译我的代码时,它没有显示错误.但是当我运行它时,它显示以下运行时错误:

java.lang.NoClassDefFoundError: org/apache/http/concurrent/FutureCallback
at com.mashape.unirest.request.BaseRequest.asJson(BaseRequest.java:68)
at PAskMe.PAskMe.main(PAskMe.java:14)
at PAskMe.__SHELL0.run(__SHELL0.java:6)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at bluej.runtime.ExecServer$3.run(ExecServer.java:725)

Caused by: java.lang.ClassNotFoundException: org.apache.http.concurrent.FutureCallback
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 8 more

我已将这些罐子包含在我的项目中:

但我仍然得到错误.请帮我.

解决方法

下载httpcore-4.2.3.jar并将其添加到您的类路径中.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读