我正在与 riak 合作。试图从 Java 访问它。这是代码:
package eee.xxx;
import com.basho.riak.client.IRiakClient;
import com.basho.riak.client.RiakException;
import com.basho.riak.client.RiakFactory;
import com.basho.riak.client.bucket.Bucket;
public class Main {
/**
* @param args
* @throws RiakException
*/
public static void main(String[] args) throws RiakException {
IRiakClient myClient = RiakFactory.httpClient("127.0.0.1");
Bucket myBucket = myClient.fetchBucket("Pacan").execute();
}
}
编译后,它会抛出这样的错误:
Exception in thread "main" java.lang.NoClassDefFoundError: org/json/JSONException
at com.basho.riak.client.raw.http.HTTPClientAdapter.<init>(HTTPClientAdapter.java:85)
at com.basho.riak.client.RiakFactory.httpClient(RiakFactory.java:144)
at eee.xxx.Main.main(Main.java:18)
Caused by: java.lang.ClassNotFoundException: org.json.JSONException
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)
... 3 more
我不知道如何解决这个问题。请帮忙!:-)