No converter found capable of converting from type [org.bson.types.ObjectId] to type [java.lang.Inte

超、凢脫俗 2024-04-01 14:50 181阅读 0赞

No converter found capable of converting from type [org.bson.types.ObjectId] to type [java.lang.Integer]

92436137a5fc4727a8c0911e86c46f84.png

在使用MongoDB进行查询时报错

报错语句为 类型不兼容,表里的字段类型与实体类字段类型不符

查看MongoDB 与实体类对比

753e06ae483e462da7afe7b5a1fea270.png

f11648ed80aa461dbdf01e1cbf9678ba.png

结果发现二者没有任何区别这就让人纳闷,我怀疑是以为mongoDB自带的 _id 会让JAVA 误以为是 id ,修改字段名与实体类名;

1233f8e3274a4eb789cb6aefb7725898.png

aa6344508e9a4df3972566ed8cfd36fa.png

重新启动测试一下

afb934ed82944baf898b75328173d0a9.png

完美解决,原因:两个ID冲突了

发表评论

表情:
评论列表 (有 0 条评论,181人围观)

还没有评论,来说两句吧...

相关阅读