@Repeatable

对同一种注解多次使用就会使用到@Repeatable

@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.ANNOTATION_TYPE)
public @interface Repeatable {

举例:

1. 申明RolesTest注解包含多重角色

@Documented
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface RolesTest {RoleTest[] value();
}

2.申明RoleTest注解

@Documented
@Repeatable(RolesTest.class)
public @interface RoleTest {String value() default "";
}

3. 申明测试类,设定多重角色

@RoleTest("apple")
@RoleTest("pear")
@RoleTest("orange")
public class MainRepeatable {}

4. 单元测试:

    @Testpublic void testRepeat(){if(MainRepeatable.class.isAnnotationPresent(RolesTest.class)) {RolesTest rt=MainRepeatable.class.getAnnotation(RolesTest.class);for(RoleTest t:rt.value()){logger.info(t.value());}}}

5.结果:

springboot注解@Repeatable相关推荐

  1. 十、springboot注解式AOP(@Aspect)统一日志管理

    springboot注解式AOP(@Aspect)统一日志管理 简介 AOP为Aspect Oriented Programming的缩写,意为:面向切面编程,通过预编译方式和运行期动态代理实现程序功 ...

  2. SpringBoot注解大全(转)

    原文链接:[springBoot系列]--springBoot注解大全 一.注解(annotations)列表  @SpringBootApplication:包含了@ComponentScan.@C ...

  3. spring-boot注解详解(三)

    1.SpringBoot/spring @SpringBootApplication: 包含@Configuration.@EnableAutoConfiguration.@ComponentScan ...

  4. spring-boot注解详解(一)

    spring-boot注解详解(一) @SpringBootApplication @SpringBootApplication = (默认属性)@Configuration + @EnableAut ...

  5. @configuration注解_超级全面的 SpringBoot 注解介绍,每一个用途都应该清晰

    一.注解(annotations)列表 1.@SpringBootApplication 包含了@ComponentScan.@Configuration和@EnableAutoConfigurati ...

  6. 【SpringBoot 】SpringBoot注解详解

    [SpringBoot ]SpringBoot注解详解 一.注解(annotations)列表  @SpringBootApplication:包含了@ComponentScan.@Configura ...

  7. SpringBoot : 注解@Resource

    1.美图 2.概述 在项目开发中,@Autowired和@Resource之争,一直搞不清楚,反正也不想搞清楚到底什么时候用@Autowired,什么场景下用@Resource,就一直用@Autowi ...

  8. SpringBoot注解把配置文件自动映射到属性和实体类实战

    SpringBoot注解把配置文件自动映射到属性和实体类实战 简介:讲解使用@value注解配置文件自动映射到属性和实体类 1.配置文件加载 方式一 1.Controller上面配置 @Propert ...

  9. SpringBoot注解--@SpringBootApplication/@MapperScan/自定义启动类注解

    原文网址:SpringBoot注解--@SpringBootApplication/@MapperScan/自定义启动类注解_IT利刃出鞘的博客-CSDN博客 简介 本文介绍SpringBoot启动类 ...

最新文章

  1. PHP文本处理 中文汉字字符串 转换为数组
  2. vue 添加完数据后刷新页面_vue form 表单提交后刷新页面的方法
  3. MobaXterm无法退格删除,出现^H
  4. HDU 3966 Aragorn's Story (树链剖分+线段树)
  5. django界面上弹出bootstrap modal对话框,对话框中包含iframe并请求一个新的页面
  6. Git学习文档之一 学习文档-并行开发
  7. 回顾JavsScript对象的克隆
  8. matlab常用函数
  9. mysql packet_mysql配置: max_allowed_packet
  10. Intent.ACTION_VIEW
  11. 【Day4.7】错过湄南河夜游,去河畔夜市晚餐
  12. 长文详解材料阻燃性能试验方法
  13. 酷冷战神 先手致胜:腾讯ROG游戏手机6为游戏而生
  14. 加密解密--换行符作祟
  15. PPT之幻灯片中的大纲选项卡
  16. 【前端期末作业 基于jQuery鲜花销售管理系统】
  17. Android驱动-霍尔摁键hall_sensor的实现
  18. Python应用开发
  19. 源码分析 - Spring Security OAuth2 生成 token 的执行流程
  20. Dos命令简单操作入门操作

热门文章

  1. 用java写了一个计算器(两个数的加减乘除运算)
  2. 首播过亿,火爆全网,我分析了《乘风破浪的姐姐》,发现了这些秘密
  3. GeoServer导入ArcGIS的shp文件样式丢失:自定义Style
  4. Windows 7 无法登陆网银
  5. 统计数据库下每张表的数据量
  6. 《Dokcer的使用》(三) 镜像仓库和镜像
  7. 网络安全的行业黑话 ——攻击篇 之攻击者
  8. php自定义json字符串,php自定义json_encode()和json_decode()函数
  9. CSS阴影样式大全(包含所有样式: demo代码全)看图看代码
  10. 物联网 实验2 Mind+ 掌控板