zoukankan      html  css  js  c++  java
  • Spring boot 注解简单备忘


    Spring boot 注解简单备忘

      1.定义注解

    package com.space.aspect.anno;
    import
    java.lang.annotation.*; /** * 定义系统日志注解 * @date 2018/6/4 9:24 */ @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) @Documented public @interface SysLog { String value() default ""; }

    2.关键注解的解释

      

    java中元注解有四个: @Retention @Target @Document @Inherited;
    
      @Retention:注解的保留位置         
      @Retention(RetentionPolicy.SOURCE)   //注解仅存在于源码中,在class字节码文件中不包含
      @Retention(RetentionPolicy.CLASS)     // 默认的保留策略,注解会在class字节码文件中存在,但运行时无法获得,
      @Retention(RetentionPolicy.RUNTIME)  // 注解会在class字节码文件中存在,在运行时可以通过反射获取到
      
      @Target:注解的作用目标      
      @Target(ElementType.TYPE)   //接口、类、枚举、注解
      @Target(ElementType.FIELD) //字段、枚举的常量
      @Target(ElementType.METHOD) //方法
      @Target(ElementType.PARAMETER) //方法参数
      @Target(ElementType.CONSTRUCTOR)  //构造函数
      @Target(ElementType.LOCAL_VARIABLE)//局部变量
      @Target(ElementType.ANNOTATION_TYPE)//注解
      @Target(ElementType.PACKAGE) ///包   
     
       @Document:说明该注解将被包含在javadoc中
     
      @Inherited:说明子类可以继承父类中的该注解

    记录一下,以免忘却了.

  • 相关阅读:
    hdu6761 Mininum Index // lyndon分解 + duval贪心 + 秦九韶算法
    hdu6762 Mow // 半平面交 模拟 双端队列
    数据库增删改查操作
    移动端自动化概念
    范围查询和模糊查询
    软件测试技能要求总结
    继承
    luogu_P2024 [NOI2001]食物链
    luogu_P4092 [HEOI2016/TJOI2016]树
    luogu_P2887 [USACO07NOV]防晒霜Sunscreen
  • 原文地址:https://www.cnblogs.com/mbailing/p/java-aop-annotation.html
Copyright © 2011-2022 走看看