@Column(name = "user_sort", columnDefinition = "int(11) comment '排序'") private Integer userSort;
@ApiModel(value = "用户信息") @Entity // Indexes是声明表里的索引,columnList是索引的列,同时可声明此索引列是否唯一, @Table(name = "fls_user", indexes = {@Index(name = "userMobile", columnList = "userMobile", unique = true)}) public class User implements Serializable { private static final long serialVersionUID = 1092120369362179355L; @ApiModelProperty(value = "ID", hidden = true) @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Integer id; @ApiModelProperty(value = "排序") @Column(name = "user_sort", columnDefinition = "int(11) comment '排序'") private Integer userSort; @ApiModelProperty(value = "用户电话") @Column(name = "user_mobile", unique = true, columnDefinition = "int(11) comment '手机'") private String userMobile; @ApiModelProperty(value = "用户密码") @JsonIgnore @Column(name = "user_password", columnDefinition = "varchar(50) comment '密码'") private String userPassword; @ApiModelProperty(value = "用户图片") @Column(name = "user_photo", columnDefinition = "varchar(255) comment '头像'") private String userPhoto; @ApiModelProperty(value = "真实姓名") @Column(name = "user_realname", nullable = false, columnDefinition = "varchar(50) comment '姓名'") private String userRealName; @ApiModelProperty(value = "启用状态") @Column(name = "user_on", nullable = false, columnDefinition = "int(1) default 0 comment '启用状态:0:启用,1:禁用,2,:已删除'") // 默认启用 private Integer userOn = EnumUtils.UserEnum.NORMAL.getValue(); @ApiModelProperty(value = "当前单位") @Column(name = "user_company", columnDefinition = "int(11) comment '当前单位'") private Integer userCompany; @ApiModelProperty(value = "当前角色") @Column(name = "user_role", columnDefinition = "int(11) comment '当前角色'") private Integer userRole; @ApiModelProperty(value = "扩展角色") @Lob @Basic(fetch = FetchType.LAZY) @Column(name = "user_extend_role", columnDefinition = "text comment '扩展角色'") private String userExtendRole; ———————————————— 版权声明:本文为CSDN博主「表演系小学渣」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。 原文链接:https://blog.csdn.net/weixin_41996632/article/details/107554011
生成表截图如下
说明:有时候会出现以下异常,出现后当创建完成自己的索引后,删除掉自动创建的索引即可
当索引unique为true时,第二次启动时会创建名称为user_mobile的索引,此时删掉自动创建的索引即可
当索引unique为false时,若不需要则手动删除自动创建的索引
————————————————
版权声明:本文为CSDN博主「表演系小学渣」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:
https://blog.csdn.net/weixin_41996632/article/details/107554011站长微信:xiaomao0055
站长QQ:14496453