我正在使用Unirest,但无法发出简单的GET请求。
这是我的简单代码:
package momoBot;
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;
public class Main {
public static void main(String[] args) throws Exception {
final HttpResponse<String> response = Unirest.get("https://httpbin.org/get").asString();
System.out.println(response.getBody());
}
}
这是我遇到的错误:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/HttpRequest
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at com.mashape.unirest.request.BaseRequest.asString(BaseRequest.java:56)
at momoBot.Main.main(Main.java:9)
Caused by: java.lang.ClassNotFoundException: org.apache.http.HttpRequest
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 14 more