阅读背景:

java8新特性终-重复注解和类型注解(内含福利)

来源:互联网 

自定义注解

import java.lang.annotation.Repeatable;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;


@Repeatable(MyAnnotions.class)//需要使用重复注解指定容器
@Target(value={java.lang.annotation.ElementType.TYPE,java.lang.annotation.ElementType.FIELD,java.lang.annotation.ElementType.METHOD,java.lang.annotation.ElementType.PARAMETER,java.lang.annotation.ElementType.CONSTRUCTOR,java.lang.annotation.ElementType.LOCAL_VARIABLE,java.lang.annotation.ElementType.TYPE_PARAMETER})
//目标  TYPE_PARAMETER  类型注解
@Retention(value=java.lang.annotation.RetentionPolicy.RUNTIME)//生命周期
public @interface MyAnnotation {
   
	String value()default "test01";
	
}import java.lang.annotation.Repeatable;



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: