gpt4 book ai didi

java - Riak Java客户端编译失败

转载 作者:行者123 更新时间:2023-12-01 14:58:24 26 4
gpt4 key购买 nike

我正在与 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

我不知道如何解决这个问题。请帮忙! :-)

最佳答案

Riak有许多第三方库依赖项,其中之一是您似乎缺少的标准 JSON 库。它需要在编译和运行时在类路径上可用。可以查到here .

由于大约有 8 个依赖项,因此更容易让 Maven通过添加依赖项来为您管理它:

<dependency>
<groupId>com.basho.riak</groupId>
<artifactId>riak-client</artifactId>
<version>1.0.6</version>
</dependency>

关于java - Riak Java客户端编译失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14035202/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com