springboot 数据库新增值 Could not set property 'id' of '.... +【argument type mismatch】

 

用mybatispluc往数据库新增值一直提示 Could not set property 'id' of ' “xxxxxxxxxxxxxxx”

并且报argument type mismatch错误  参数类型不匹配

 

原因是数据库主键自动自增  和 mybatisplus自动递增方式不同

mybatisplus默认帮我设置为雪花算法生成主键id  是长串类型 xxxxxxxxxxxxxxx

 

解决方法:

实体类自己加上主键自增类型,不要用mybatisplus默认的

    @TableId(type = IdType.AUTO)
    Integer id;//主键id

设置成这个就是自己数据库默认的递增方式了。

 

posted @ 2022-03-09 13:18  Hello霖  阅读(259)  评论(0编辑  收藏  举报