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;
}
Read More:
- Hibernate Error: Error executing DDL “create table course (xxx)“
- Asynchronous processing of HTTP request by Java_ Method 2: through deferredresult
- [Solved] Hibernate Error: java.lang.StackOverflowError at java.lang.Integer.toString(Integer.java:402)
- Mybatis sets the primary key Auto-Increment error: No setter found for the keyProperty
- Spring boot uses thread pool to realize asynchronous processing without return and asynchronous processing with return
- Implementation of retrial mechanism in Java
- Mybatis plus paging Plugin and Auto-fill
- MP Error: ‘getBaseMappe ServiceImpl’ clashes [How to Solve]
- Asynchronous processing of HTTP request by Java_ Method 1: through callable
- [Solved] Idea Build error. The symbol — Lombok cannot be found
- [Solved] IDEA java Cannot resolve method ‘getName‘ in ***
- SpringCloud Use openFeign Multipartfile to Upload Files Error: Current request is not a multipart request
- Springboot controls the startup of rabbitmq through configuration files
- Code case of XXL job executor
- I/O error while reading input message; nested exception is java.io.IOException: Stream closed
- [Solved] Consider defining a bean of type ‘org.springframework.data.redis.core.RedisTemplate‘ in your configu
- [Solved] mybatisplus BaseMapper Error: required a single bean, but 2 were found
- Mybatisenumtypehandler upgrade error of mybatis plus
- [Solved] Method threw ‘java.lang.StackOverflowError‘ exception. Cannot evaluate
- How to Use filechannel to copy files