假设有一个@YourAnnotation注解。在一个方法上放置两次:
@YourAnnotation
@YourAnnotation
public void test(){
//TODO
}
会看到IDE报错:
Duplicate annotation @YourAnnotation. Repeated annotations are allowed only at source level 1.8 or above
当然,即使是使用Java8按1.8编译也会报错:
Duplicate annotation of non-repeatable type @YourAnnotation. Only annotation types marked @Repeatable can be used multiple times at one target.
但是,后面一句告诉我们,有解决的办法,这也说明Java8支持重复注解。来看具体怎么做:
先写一个...... 【阅读全文】
SEO:多注解,multiple annotations,多次注解,多次使用注解,同一位置多次使用注解,方法上多个同一注解,方法上多个注解报错,