关于注解的使用说明

@Target注解
声明可以使用的对象
@Target{Elemtype.xxx}
Elemtype 为枚举类

public enum ElementType {
   //类接口或者泛型的声明
    TYPE,

  //域声明
    FIELD,

//方法声明
    METHOD,

//参数声明
    PARAMETER,

//构造器声明
    CONSTRUCTOR,

//本地变量声明
    LOCAL_VARIABLE,

 //声明
    ANNOTATION_TYPE,

//包
    PACKAGE,

//参数
    TYPE_PARAMETER,

//使用
    TYPE_USE
}

@Retention注解:注解的存在位置
使用@Retention{RetentionPolicy.xxx}
RententionPolicy枚举类

public enum RetentionPolicy {
    /**
     * Annotations are to be discarded by the compiler.源文件
     */
    SOURCE,

    /**
     * Annotations are to be recorded in the class file by the compiler
     * but need not be retained by the VM at run time.  This is the default
     * behavior.class文件
     */
    CLASS,

    /**
     * Annotations are to be recorded in the class file by the compiler and
     * retained by the VM at run time, so they may be read reflectively. 运行时
     *
     * @see java.lang.reflect.AnnotatedElement
     */
    RUNTIME
}

@Documented 注解会把加该注解的对象加入到javadoc下
@Component 注入到Spring工厂中去
@Aspect Aop的面向切面
@Slf4j 日志文件的注解
@autowried自动注入对象 ,必须再Spring 工厂中注册
@PointCut()
里面可以“@annocation(注解名称)”来声明切入的地方,也可用传统的execute的方式
@Before @around 一个是环绕一个是之前 用execute的方式可以不用单独写@pointcut,否则则是该方法 调用@Around(“xxx”)…xxx为pointcut后的方法

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值