以前没有用过这个,作为记录,参考帖子https://www.cnblogs.com/luoaz/p/4691639.html
DBCollection collection = configMongoTempleate.getCollection("集合名称"); BasicDBObject eq = new BasicDBObject("$eq",inMailId);//$eq 表示等于 BasicDBObject queryObject = new BasicDBObject("im_mail_id",eq);//字段名称 DBCursor cursor = collection.find(queryObject); while(cursor.hasNext()){ DBObject obj = cursor.next(); System.out.println(obj.toString()); }