我正在跟随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)
答案 0 :(得分:0)
default-java / jre / lib / ext / couchbase-lite-java-1.4.1.jar 中的jar文件与类冲突