字段校验报错:"HV000030: No validator could be found for constraint 'javax.validation.constraints.NotBlank' validating type 'java.lang.Integer'. Check configuration for 'themeLevel'"
报错原因:不能使用@NotBlank(message="xxx")对Integer基本类型进行校验
解决:使用@NotNull校验
总结:
- @NotNull 适用于引用类型(Object)和包装类型(如Integer、String等)不为null,但不包括基本数据类型(如int、double等,因为它们不能为null);
- @NotEmpty 适用于集合、数组和字符串,确保非null且内容不为空;
- @NotBlank 仅适用于字符串,确保非null且至少包含一个非空白字符;