关注此文章:http://mongodb.github.io/mongo-java-driver/3.10/driver/getting-started/quick-start/
但是当我尝试将文档插入集合中时出现无法解决的符号错误,我不知道如何解决它:
MongoClient mongoClient = new MongoClient("localhost", 27017);
MongoDatabase db = mongoClient.getDatabase("mydb");
MongoCollection<Document> collection = db.getCollection("test");
Document doc = new Document("name", "MongoDb")
.append("type", "database")
.append("count", 1)
.append("versions", Arrays.asList("v3.2", "v3.0", "v2.6"))
.append("info", new Document("x", 203).append("y", 102));
collection.insertOne(doc); // unresolved symbol error here!!
这是我正在使用的驱动程序版本:
compile 'org.mongodb:mongodb-driver:3.10.1'