3
我正在使用mongodriver在Java上運行一些聚合方法,但是bson庫無法映射Document實例,但我不確定它的實際原因。Java Bson庫無法映射文檔對象
錯誤我收到:在SBT文件
java.lang.NoClassDefFoundError: org/bson/Document
at services.ApplianceServiceImpl.aggregate(ApplianceServiceImpl.java:361)
at controllers.AdminController.aggregate(AdminController.java:394)
BSON和Mongodriver聲明:
libraryDependencies ++= Seq(
"org.mongodb.morphia" % "morphia" % "0.108",
"org.mongodb.morphia" % "morphia-logging-slf4j" % "0.108",
"org.mongodb.morphia" % "morphia-validation" % "0.108",
"org.mongodb" % "bson" % "3.0.4",
"org.mongodb" % "mongodb-driver" % "3.0.4",
Java代碼:
public PaginationWrapper aggregate(FormRequest formData){
List r = new ArrayList();
int c=0;
try{
List l = asList(new Document("$group", new Document("_id", formData.field).append("count", new Document("$sum", 1))));
Iterator i = db.getCollection(formData.collection).aggregate(l).results().iterator();
while(i.hasNext()){
r.add(i.next());
c++;
}
}catch (Error e){
e.printStackTrace();
}
return new PaginationWrapper(c, r);
}
代碼在線路出現故障時以'列表l = asList(新...'
你覺得我做錯了什麼?