我正在使用来自https://github.com/AsyncHttpClient/async-http-client的示例代码,我正在尝试创建一个 GET 请求:
package asyncHttpClient;
import com.ning.http.client.*;
import java.util.concurrent.Future;
public class AsyncHttpClientExchange {
public static void main(String[] args) throws Exception {
AsyncHttpClient client = new AsyncHttpClient();
Future<Response> f = client.prepareGet("http://www.ning.com/").execute();
Response r = f.get();
System.out.println(r);
client.close();
}
}
当我尝试从我的 Eclipse 启动它时,我收到了这个错误:
Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at com.ning.http.client.AsyncHttpClient.<clinit>(AsyncHttpClient.java:152)
at asyncHttpClient.AsyncHttpClientExchange.main(AsyncHttpClientExchange.java:10)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 2 more
我的 Eclipse 或代码有问题吗?我能做些什么?非常感谢。