java - CouchBase-lite - 无法应用管理器中的上下文

标签 java intellij-idea nosql couchbase-lite

我正在关注instruction在 IntelliJ Ubuntu 中设置 CouchBase-lite。

问题是无法应用JavaContext。知道为什么吗?

package com.couchbase.HelloCBL;

import com.couchbase.lite.*;
import com.couchbase.lite.replicator.Replication;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;

public class Main {

public static void main(String[] args) {

    // Enable logging
    Logger log = Logger.getLogger("app");
    log.setLevel(Level.ALL);
    JavaContext context = new JavaContext();

    // Create a manager
    Manager manager = null;
    try {
            manager = new Manager(context, Manager.DEFAULT_OPTIONS); // THIS LINE DOES NOT COMPILE
    } catch (IOException e) {
            e.printStackTrace();
    }

    // Create or open the database named app
    Database database = null;
    try {
            database = manager.getDatabase("app");
    } catch (CouchbaseLiteException e) {
            e.printStackTrace();
    }

    // The properties that will be saved on the document
    Map<String, Object> properties = new HashMap<String, Object>();
    properties.put("title", "Couchbase Mobile");
    properties.put("sdk", "Java");

    // Create a new document
    Document document = database.createDocument();

    // Save the document to the database
    try {
            document.putProperties(properties);
    } catch (CouchbaseLiteException e) {
            e.printStackTrace();
    }

    // Log the document ID (generated by the database)
    // and properties
    log.info(String.format("Document ID :: %s", document.getId()));
    log.info(String.format("Learning %s with %s", (String) document.getProperty("title"), (String) document.getProperty("sdk")));

    // Create replicators to push & pull changes to & from Sync Gateway.
    URL url = null;
    try {
            url = new URL("http://localhost:4984/hello");
    } catch (MalformedURLException e) {
            e.printStackTrace();
    }
    Replication push = database.createPushReplication(url);
    Replication pull = database.createPullReplication(url);
    push.setContinuous(true);
    pull.setContinuous(true);

    // Start replicators
    push.start();
    pull.start();

  }
}

行中的错误消息

manager = new Manager(context, Manager.DEFAULT_OPTIONS); 

错误信息

管理器中的管理器 (com.couchbase.lite.Context,ManagerOptions) 无法应用于 (com.couchbase.lite.JavaContext,ManagerOptions)

最佳答案

default-java/jre/lib/ext/couchbase-lite-java-1.4.1.jar 中有一个 jar 文件与类冲突

关于java - CouchBase-lite - 无法应用管理器中的上下文,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48178139/

相关文章:

java - 没有从服务器获得任何响应,但能够从 telnet 获得响应

java - 如何使用 JDK 7 在 Mac OS X 上运行 IDEA IntelliJ?

azure - Azure 表存储的替代方案

nosql - 使用 HBase 和/或 Cassandra 进行搜索(和一般查询)(最佳实践?)

java - YouTube 插入错误凭据

java - 使用|在 java

maven - 使用 Kotlin 综合属性

javascript - Firebase 使用键节点排序/过滤

java - 将 java 字节数组转换为字符串

java - 与资源一起部署war文件