作者:厮守这一季德冬天_262 | 来源:互联网 | 2023-10-12 17:32
是的,有可能。只需像这样创建自己的注释:
@Documented
@Constraint(validatedBy = {})
@Target({ ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE })
@Retention(RetentionPolicy.RUNTIME)
@ReportAsSingleViolation
@NotEmpty
@Length(min = 2, max = 35)
public @interface MyAnnotation {
public abstract String message() default "{mypropertykey}";
public abstract Class>[] groups() default {};
public abstract Class>[] payload() default {};
}
重要的部分是@ReportAsSingleViolation批注