//首先在实体用注解TableId告诉SpingBoot你的ID是自增长。
@Data
public class Book {
@TableId(value = "id", type = IdType.AUTO)
private Integer id ;
private String type ;
private String name ;
private String description ;
}
//其次在YML中说明ID自增长( id-type: auto)
mybatis-plus:
global-config:
db-config:
table-prefix: tbl_
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
id-type: auto