1. javax.validation.UnexpectedTypeException: HV000030: No validator could be found for constraint 'javax.validation.constraints.NotEmpty' validating type 'java.lang.Integer'. Check configuration for 'roleId'
at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintTree.getExceptionForNullValidator(ConstraintTree.java:108) ~[hibernate-validator-6.0.17.Final.jar:6.0.17.Final]
at .................
@NotEmpty注解支持字符串类型字段,不支持Integer,对Integer类型的校验要用@NotNull
2. org.springframework.orm.jpa.JpaSystemException: ids for this class must be manually assigned before calling save(): com.neptunus.data.modules.sys.model.entity.SysUserRole; nested exception is org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): com.neptunus.data.modules.sys.model.entity.SysUserRole
at org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(HibernateJpaDialect.java:352) ~[spring-orm-5.1.10.RELEASE.jar:5.1.10.RELEASE]
id的生成错误,在保存之前,需先生成
在实体类字段id前加上下面这句话即可
@GeneratedValue(strategy = GenerationType.IDENTITY)