|
问题:
在boot 使用mybatis-plus 时,调用方法,提示如下信息: This primary key of "userId" is primitive !不建议如此请使用包装类 in Class: "com.gxa.boot345.entity.pojo.User" 原因: 本质就是mybatis-plus会对字段是不是原始类型进行验证。 原始类型就是:byte,char,short,int,long,boolean,float,double 解决办法很简单:就是使用基本类型对应的类类型。 为什么要这么用:因为原始类型的本质不是面向对象的,java为了方便使用,就创造了原始类型对应的面向对象的类型及类类型或包装类型。 代码如下: @TableId(value = "userId",type = IdType.AUTO) private int userId; 改为 @TableId(value = "userId",type = IdType.AUTO) private Integer userId; 原文链接:https://blog.csdn.net/tangshiyilang/article/details/136864683 |
|
|