mybatis-plus坑之insert方法

insert方法默认底层会增加id字段 ,无论你传没传

如:

User user = new User("张三", "456", "15526538456");      
 boolean result = userService.insert(user);

并没有传递User中的id主键字段  ,plus会自动生成一个

但是!!!自动生成一个长的字符串 

如:1004237803871014914


所以我们使用此方法 必须  在数据库id字段设置成bigint类型 (不然放不下这么长的数字)

然后在pojo中 id属性就不能为int和Integer 了 

如: 

猜你喜欢

转载自blog.csdn.net/wuhaotian1996/article/details/80594552