第一次尝试使用MongoDB对实体进行插入操作,结果出现 Cannot autogenerate id of type java.lang.Integer for entity of type com.mongodb.pojo.User!
大概意思是不能将ID转换为Integer

MongoDB默认的集合主键是“_id”,类型是ObjectId。
ObjectId是一个12字节的BSON类型字符串,包含了UNIX时间戳,机器识别码,进程号,计数值信息。机器码用来防止分布式系统生成id时冲突的问题,保证每台机器生成的识别码不同,进程号保证多线程情况下生成的id不同。ObjectId保证了_id的唯一性。

所以,将主键ID的类型改为ObjectId(org.bson.types.ObjectId)即可。

Cannot autogenerate id of type java.lang.Integer for entity of type com.mongodb.pojo.User!相关推荐

  1. Cannot autogenerate id of type java.lang.Integer for entity

    在直接对MongoDB中插入实体对象的时候出现了 Cannot autogenerate id of type java.lang.Integer for entity org.springframe ...

  2. MongoDB-Cannot autogenerate id of type java.lang.Long for entity of type

    错误 org.springframework.dao.InvalidDataAccessApiUsageException: Cannot autogenerate id of type java.l ...

  3. Failed to convert property value of type java.lang.String to required type java.lang.Integer for pro

    Failed to convert property value of type java.lang.String to required type java.lang.Integer for pro ...

  4. no suitable HttpMessageConverter found for request type [java.lang.Integer]

    今天在使用Spring Template的时候遇到了这个异常: no suitable HttpMessageConverter found for request type [java.lang.I ...

  5. RestTemplate异常no suitable HttpMessageConverter found for request type [java.lang.Integer]

    RestTemplate异常no suitable HttpMessageConverter found for request type [java.lang.Integer] 参考文章: (1)R ...

  6. 报错JSON parse error: Cannot deserialize value of type `java.lang.Integer` from String

    前端界面报错 JSON parse error: Cannot deserialize value of type java.lang.Integer from String "777777 ...

  7. 控制台There is no getter for property named id in class java.lang.Integer问题解决

    解决There is no getter for property named 'id' in 'class java.lang.Integer'问题 写后台业务时,有个通过id查询单条数据的需求,写 ...

  8. No validator could be found for constraint ‘javax....NotEmpty‘ validating type ‘java.lang.Integer‘

    问题概述 在应用系统项目开发过程中,使用jakarta.validation-api进行数据实体字段校验时遇到一个梗," javax.validation.UnexpectedTypeExc ...

  9. 【Bug】No validator... javax.validation.constraints.NotBlank validating type java.lang.Integer

    javax validation 报错: HV000030: No validator could be found for constraint 'javax.validation.constrai ...

最新文章

  1. 【新书】分布式强化学习
  2. php转移动,php移动或拷贝文件夹
  3. 【笨木头Lua专栏】基础补充08:协同程序之resume-yield间的数据返回
  4. 时差法超声波流量计的原理
  5. 2.1.4 什么是ASCII码?汉字的表示和编码是怎样的?
  6. python发邮件11002_【python发送zabbix报警邮件,SSL版本】mailman.py
  7. geek_Ask How-To Geek:营救受感染的PC,安装无膨胀iTunes和驯服疯狂的触控板
  8. C#通过属性名字符串获取、设置对象属性值
  9. 360产品演示代码 css3 html5,HTML5 CSS3代码的三维展示
  10. 【Http】PKIX(PKIX path building failed) 问题 unable to find valid certification path to requested target
  11. 南理工14级第4组软件课程设计报告
  12. Pytorch——Window上Pytorch的安装教程
  13. 学习SQL 的网址集合
  14. VS Code 轻量级插件推荐
  15. 《VP9 Levels and Decoder Testing》笔记
  16. 新域名后缀的主要优点是什么?
  17. nginx通过url跳转到另外的一个url上
  18. 用万用表判断三极管极性
  19. 分布式事务框架TX-LCN
  20. 支付宝免签 个人支付宝到银行卡

热门文章

  1. git 主干修改合并到分支_这才是真正的 Git——分支合并
  2. freeswitch之呼叫中心acd模块开发
  3. php sprintf 小数,php sprintf函数
  4. php字符串截取所有函数,PHP字符串截取函数大全
  5. mysql数据库如何做缓存_MySql数据库缓存
  6. win10+php+com组件,分享Win10系统打不开COM组件提示错误代码80040154的解决方法
  7. CGLIB中BeanCopier源码实现
  8. 命令行删除目录下指定日期前文件
  9. 计算机学院 铁道交通运营管理,成都动车学校铁道交通运营管理专业
  10. 计算机级别对应职称,2016年职称计算机怎么分级别