[英]Custom Class Level Validation - Creating the Annotation
我想在Spring Boot v1.5.14.RELEASE應用程序中實現自定義驗證器。 首先,我創建一個自定義約束注釋:
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@Retention(RetentionPolicy.RUNTIME)
public interface CreateBook {
}
但是,我收到此編譯錯誤:
@Retention not applicable to type
問題在於如何定義新注釋。 它應該是這樣的:
@Retention(RetentionPolicy.RUNTIME)
public @interface CreateBook {
}
注意@interface
的@
字符
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.