在注解上使用@Inherited 表示该注解会被子类继承,注意,仅针对类,成员属性、方法并不受此注释的影响。

对于类来说,子类要继承父类的注解需要该注解被 @Inherited 标识。
对于成员属性和方法来说,非重写的都会保持和父类一样的注解,而被实现的抽象方法,被重写的方法都不会有父类的注解。

Indicates that an annotation type is automatically inherited. If
an Inherited meta-annotation is present on an annotation type
declaration, and the user queries the annotation type on a class
declaration, and the class declaration has no annotation for this type,
then the class’s superclass will automatically be queried for the
annotation type. This process will be repeated until an annotation for this
type is found, or the top of the class hierarchy (Object)
is reached. If no superclass has an annotation for this type, then
the query will indicate that the class in question has no such annotation.

Note that this meta-annotation type has no effect if the annotated
type is used to annotate anything other than a class. Note also
that this meta-annotation only causes annotations to be inherited
from superclasses; annotations on implemented interfaces have no
effect.

@Inherited 的作用相关推荐

  1. 一篇文章带你搞定 Java 中 @Target、@Documented 和 @Inherited 注释

    文章目录 一.@Target 二.@Documented 注释 三.@Inherited 注释 一.@Target 如果一个Annotation 没有明确地指明定义的位置,则可以在任意的位置使用,例如 ...

  2. Java 注解深入理解

    内容概要 Annotation的概念 Annotation的作用 Annotation的分类 系统内置注解 元注解 自定义注解 解析注解信息 JDK8注解新特性 附:项目源码地址 一.Annotati ...

  3. 【JAVA基础篇】注解

    一.什么是注解? 注解是元数据,所谓元数据就是描述数据的数据. 在annotation诞生之前(jdk1.5诞生了注解),甚至之后,xml被广泛的由于描述元数据.但是后来,有一些应用开发工程师和架构师 ...

  4. 基于SpringBoot的后台管理系统(异常、注解、node、page)(二)

    common.exception.annotation.node.page 说明 如果您有幸能看到,请认阅读以下内容: 1.本项目临摹自abel533的Guns,他的项目 fork 自 stylefe ...

  5. 枚举型、注释(待补充)

    Enum 1.使用oublic static final表示的常量描述较为繁琐,使用enum关键字来定义枚举类型取代常量,枚举类型是从Jva5开始增加的一种引用数据类型. 2.枚举值就是当前类的类型, ...

  6. java_Annotation

    注解 annotation 什么是注解? 1. Annotation是从JDK5.0开始引入的新技术. 2. Annotation的作用: – 不是程序本身,可以对程序作出解释.(这一点,跟注释没什么 ...

  7. 啊啊,终于搞明白了,原来注解是这么一回事。6000+字理解注解【一】

    文章目录 前言 复习注解 元注解 @Retention 存活时间 @Documented 文档 @Target 目标 @Inherited 继承 @Repeatable 可重复 注解属性 注解实现-反 ...

  8. Java自定义拦截器处理防抖

    自定义注解 RepeatSubmit , 用于防止表单重复提交 package com.goodsoft.shrk.common.annotation;import java.lang.annotat ...

  9. Java工程师 面试知识总结 (个人总结)

    面试个人总结 1.基础 1.1 JVM 1.1.1 JVM五大区域 1.1.2 新生代和老年代 (1:2) 1.1.3 JVM加载类的过程 1.1.4 OOM异常 1.1.5 JVM常用调优参数 1. ...

最新文章

  1. matlab处理图像位置,MATLAB图像处理:我的直方图的最后一个位置出现了
  2. 8)排序④排序算法之归并排序
  3. [BTS06]BizTalk2006 SDK阅读笔记(五) 管道-Pipeline
  4. 在c 语言中stdio,C语言中,什么时候用到stdio.h之外的解释文件
  5. 未来已来——工作空间WorkSpace和物联网IoT (3)
  6. JS 枚举型变量操作
  7. java环境变量含义_Java环境变量的配置及意义
  8. 关于阿里巴巴iconfont的使用方法
  9. DropBlock正则化
  10. 抽象类及继承(本科生和研究生类)
  11. 计算机音乐乐谱打上花火,【B】打上花火
  12. 操作系统安装教程之图解Ubuntu Server 14.04安装
  13. Maven相关jar包安装
  14. Socket 简介及面试题
  15. xtrabackup全量备份与全量恢复
  16. 计算机速成课 第二集 电子计算机
  17. 数字内容产业的产业链结构
  18. springboot医院预约挂号系统在线视频点播系统毕业设计毕设作品开题报告开题答辩PPT
  19. Facebook 企业广告账户开户流程、资料准备、开户时间、开户须知及OE链接
  20. iOS description方法的使用介绍

热门文章

  1. SEM推广及广告投放数据分析及可视化
  2. 【linux】已加载插件:fastestmirror, langpacks Loading mirror speeds from cached hostfile
  3. 全局配置遮罩层(VUE Element Ui)
  4. 阿凡达(Avatar)迄今为止最搞笑最靠谱的2个影评
  5. CouchDB小全 --- 网上很棒的介绍CouchDB的博文
  6. 视频直播流媒体服务器的http-flv是如何直播的?
  7. 使用Tensorflow训练LSTM+Attention中文标题党分类
  8. Android.mk入门教程
  9. My MPC·暴风影音 5.00_Stable
  10. 时空大数据要把握“后发优势”