我正在使用MungDB shell版本3.3.3,并尝试执行类型的查询(来自Java):

SELECT _id, ressort, date from sample WHERE ressort != "A".

我的代码是:
MongoClient mongo = new MongoClient("localhost", 27017);
MongoDatabase database = mongo.getDatabase("local");
MongoCollection<Document> collection = database.getCollection("sample");
FindIterable<Document> findIterable = collection.find(ne("ressort","A")).projection(include("ressort", "date"));

eclipse给出了一个错误
方法include(string,string)对于类型app“是未定义的。
怎么办?
我已经完成了过滤器的静态导入。

最佳答案

include方法是类com.mongodb.client.model.Projections中的静态辅助方法。再次检查您的导入。
Here您可以找到所有助手的文档。

09-27 06:40