1. 出现错误一

  1. Specified key was too long; max key length is 1000 bytes
  2. 原因是由于字段给的大小,太大 超过了默认值 1000bytes
    1. 我设置了一个复合唯一索引 (200+200)*3 >1000 所以造成了索引构建失败
      1. 3:字符集是 utf8 ,1个utf8=3bytes
  3. 参考

    1. @Entity
    2. @Table(name ="api_environment_detection",schema = "eco",
    3. indexes={
    4. @Index(name="stationcode_receivetime_unique",columnList="stationcode,receivetime",unique=true),
    5. })
    6. @org.hibernate.annotations.Table(appliesTo = "api_environment_detection",comment = "环境检测数据")
    7. @Getter
    8. @Setter
    9. @Accessors(chain = true)
    10. public class EnvironmentDetectionEntity extends BaseEntity<EnvironmentDetectionEntity> {
    11. @Column(columnDefinition = " varchar(25) not null comment '设备编号'" )
    12. // @Column(columnDefinition = " varchar(200) not null comment '设备编号'" )
    13. private String stationcode;
    14. @Column(columnDefinition = " varchar(30) not null comment '数据时间(最后一次上报数据的时间)'" )
    15. //@Column(columnDefinition = " varchar(200) not null comment '数据时间(最后一次上报数据的时间)'" )
    16. private String receivetime;
    17. }