遍历MongoCursor<Document>报错信息:
java.util.NoSuchElementException
at com.mongodb.MongoBatchCursorAdapter.next(MongoBatchCursorAdapter.java:52)
解决方法:
执行到Document document = sendIterator.next();这句话就报错,因为sendIterator没有元素,先加sendIterator.hasNext()判断一下
MongoCursor<Document> sendIterator = sendAggregate.iterator();
Document document = sendIterator.next();
修改为:
while(sendIterator.hasNext()){
Document document = sendIterator.next();
}
本文链接:http://www.yayihouse.com/yayishuwu/chapter/1489