Tag Archives: sort

How to Solve the Primary Key of mybatisPlus Inserted Data is too Large Issue

Solve the problem that the primary key of mybatisplus inserted data is suddenly large

1. Enter the corresponding database in the administrator window, and then enter the following instructions:

alter table sys_user AUTO_INCREMENT=30;

​sys_user is the name of the data table to be modified, and 30 is to modify the self increment starting value to 30

In this way, the primary key value of the data table will return to normal

2. In the entity class of the project, add a @Tableid annotation to the primary key of the class

package baocms.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
@TableName(value = "sys_user")
public class User {
    @TableId(value = "id",type = IdType.AUTO)
    private Integer id;
    private String username;
    private String password;
    private String nickname;
    private String email;
    private String phone;
    private String address;
}