码上敲享录 > java常见报错解答 > java.util.NoSuchElementException已解决

java.util.NoSuchElementException已解决

上一章章节目录下一章 2018-08-15已有12271人阅读 评论(0)

遍历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


向大家推荐《Activiti工作流实战教程》:https://xiaozhuanlan.com/activiti
12

有建议,请留言!

  • *您的姓名:

  • *所在城市:

  • *您的联系电话:

    *您的QQ:

  • 咨询问题:

  • 提 交