1
我试图连接到Cloudant客户端,并且我已经在GitHub上找到了一个代码示例。连接到Cloudant客户端Java
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' – gerrytan
确实解决了它!我导入了javax版本:javax.ws.rs.client.ClientBuilder。谢谢! – Adam