错误提示
No converter found capable of converting from type [org.bson.BsonUndefined] to type [java.lang.Integer]
原因
mongo bson中有字段是Undefined,无法自动转成Java对象
解决方案
mongo字段有undefined的查询方法: "字段": {'$type':6}
例如: 查出手机归属地undefined,并修正成null,java就可以转换
db.customer.find("phoneLocation": {'$type':6}}).forEach(
function(item){
db.customer.update({"_id":item._id},{"$set":{"phoneLocation":null}},false,true)
}
)
本文介绍了一种在MongoDB中处理Undefined字段的方法,通过查询并更新这些字段为null,解决了从MongoDB转换到Java对象时出现的问题。
695

被折叠的 条评论
为什么被折叠?



