javax.validation.UnexpectedTypeException: HV000030: No validator could be found for constraint 'javax.validation.constraints.Size' validating type 'java.lang.Integer'. Check configuration for 'type'
原代码
@NotEmpty(message = "type:参数不能为空")
@Range(min = 1, max = 2, message = "可选值:1内容规则,2用户规则")
@ApiModelProperty("类型:1内容规则,2用户规则")
private Integer type;
报错
javax.validation.UnexpectedTypeException: HV000030: No validator could be found for constraint ‘javax.validation.constraints.Size’ validating type ‘java.lang.Integer’. Check configuration for ‘type’
原因
@NotEmpty只能用于校验 String,Collection,Map and Arrays类型
解决
校验Integer的非空,使用@NotNull
@NotNull(message = "type:参数不能为空")
@Range(min = 1, max = 2, message = "可选值:1内容规则,2用户规则")
@ApiModelProperty("类型:1内容规则,2用户规则")
private Integer type;