gpt4 book ai didi

java - 连接到 Cloudant 客户端 Java

转载 作者:行者123 更新时间:2023-11-30 03:03:26 25 4
gpt4 key购买 nike

我正在尝试连接到 Cloudant 客户端,并且我采用了在 GitHub 上找到的代码示例。

public ClientBuilder getCloudantClient(String username, String password) {
ClientBuilder clientBuilder = ClientBuilder.account(username).
username(username).password(password);
return clientBuilder;
}

理想情况下,一旦该方法返回,我尝试通过执行以下操作来构建并返回数据库:

CloudantClient client = (CloudantClient) cloudantRestClient.getCloudantClient(USERNAME, PASSWORD).build();
Database database = client.database(DATABASE, true);

但由于某种原因,我收到编译错误:

The method account(String) is undefined for the type ClientBuilder

我的 Cloudant 和 JUnit 测试的 pom.xml 依赖项如下:

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.cloudant</groupId>
<artifactId>cloudant-client</artifactId>
<version>2.3.0</version>
</dependency>

<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.19</version>
</dependency>

<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>2.22.1</version>
</dependency>

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.10.19</version>
</dependency>

我不知道我哪里错了。这是正确的方法吗?

最佳答案

您导入了错误的 ClientBuilder,请检查它是否确实是 com.cloudant.client.api.ClientBuilder

关于java - 连接到 Cloudant 客户端 Java,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35385261/

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