配置主键自增 1、实体类字段上 @TableId(type = IdType.AUTO) 2、数据库字段一定要是自增! 如果数据库字段不自增,会报下面的错: java.sql.SQLException: Field ‘id’ doesn’t have a default value