java注解

概念:Java提供了一种原程序中的元素关联任何信息和任何元数据的途径和方法。

java中预定义的常见注解:

@Overridde:检测被该注解标注的方法是否是继承自父类(接口)的

@Deprecated:该注解标注意的内容,表示已过时

@SuppressWarnings:压制警告

      *一般传递参数"all"   @SuppressWarnings("all")

/**
 * this is a study basic annotation class
 * 
 * @author kimtian
 * @date 2020.08.05
 */
@SuppressWarnings("all")
public class BaseAnnotation {

    @Override
    public String toString() {
        return "";
    }

    @Deprecated
    static void show1(){
        // 过时的方法
        System.out.println("this is a deprecated method.");
    }
    static void show2(){
        // 建议使用的新方法
        System.out.println("this is a perfect new method");
    }

    public static void main(String[] args) {
        // 过时的方法上面会有一道横线
        show1();
        // 正常方法上面不会有横线
        show2();
        
    }
}

注解分类

自定义注解

 

java注解_第1张图片

你可能感兴趣的:(Spring)