1.问题
利用mybatis插入数后。生成一长串数字。Java中的Long类型。与JS中的数值类型不进行匹配。导致js会改变
2.解决
方式1
@TableId(type = IdType.AUTO) 在实体类id加注解
@Data
@AllArgsConstructor
@NoArgsConstructor
public class UserBlog {
@TableId(type = IdType.AUTO)
private Long id;
private String title;
private String content;
private String reaseon;
private Integer status;
private Integer user_id;
@TableField(exist=false)
private String username;
}
方式2
配置类
global-config:
db-config:
id-type: auto
`mybatis-plus:
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
#下划线转驼峰 mybatis-plus默认开启 mybatis 默认关闭
#map-underscore-to-camel-case: true
typeAliasesPackage: com.qcby.shujia.demo.entity
mapperLocations: classpath:mapper/*.xml
global-config:
db-config:
id-type: auto
3.数据库修改
截断表,重置主键(因为之前使用的还是过长的id,只有重置才可以)
TRUNCATE TABLE table_name