java - 连接到 Cloudant 客户端 Java

标签 java eclipse maven cloudant

我正在尝试连接到 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/

相关文章:

java - 添加 Firebase 依赖项时出错

java - 如何抑制编译器警告?

java - Selenium 警报仅在 Debug模式下显示

eclipse - Birt:在 birt 查看器中将 rptlibrary 文件放在哪里?

maven - 我如何告诉 Maven 从自定义 Nexus 存储库中获取最新版本的 Artifact

基于 os 系列的 maven 条件

java - 选择这些 : django + smartGWT seems like the good way to go? 吗

eclipse - 在 Eclipse java 项目中,将 git 存储库从旧的更改为新的

java - Eclipse java 代码完成列表导航

java - 如何在多模块项目中配置 Maven shade 插件?