springboot注解@Repeatable
@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相关推荐
- 十、springboot注解式AOP(@Aspect)统一日志管理
springboot注解式AOP(@Aspect)统一日志管理 简介 AOP为Aspect Oriented Programming的缩写,意为:面向切面编程,通过预编译方式和运行期动态代理实现程序功 ...
- SpringBoot注解大全(转)
原文链接:[springBoot系列]--springBoot注解大全 一.注解(annotations)列表 @SpringBootApplication:包含了@ComponentScan.@C ...
- spring-boot注解详解(三)
1.SpringBoot/spring @SpringBootApplication: 包含@Configuration.@EnableAutoConfiguration.@ComponentScan ...
- spring-boot注解详解(一)
spring-boot注解详解(一) @SpringBootApplication @SpringBootApplication = (默认属性)@Configuration + @EnableAut ...
- @configuration注解_超级全面的 SpringBoot 注解介绍,每一个用途都应该清晰
一.注解(annotations)列表 1.@SpringBootApplication 包含了@ComponentScan.@Configuration和@EnableAutoConfigurati ...
- 【SpringBoot 】SpringBoot注解详解
[SpringBoot ]SpringBoot注解详解 一.注解(annotations)列表 @SpringBootApplication:包含了@ComponentScan.@Configura ...
- SpringBoot : 注解@Resource
1.美图 2.概述 在项目开发中,@Autowired和@Resource之争,一直搞不清楚,反正也不想搞清楚到底什么时候用@Autowired,什么场景下用@Resource,就一直用@Autowi ...
- SpringBoot注解把配置文件自动映射到属性和实体类实战
SpringBoot注解把配置文件自动映射到属性和实体类实战 简介:讲解使用@value注解配置文件自动映射到属性和实体类 1.配置文件加载 方式一 1.Controller上面配置 @Propert ...
- SpringBoot注解--@SpringBootApplication/@MapperScan/自定义启动类注解
原文网址:SpringBoot注解--@SpringBootApplication/@MapperScan/自定义启动类注解_IT利刃出鞘的博客-CSDN博客 简介 本文介绍SpringBoot启动类 ...
最新文章
- PHP文本处理 中文汉字字符串 转换为数组
- vue 添加完数据后刷新页面_vue form 表单提交后刷新页面的方法
- MobaXterm无法退格删除,出现^H
- HDU 3966 Aragorn's Story (树链剖分+线段树)
- django界面上弹出bootstrap modal对话框,对话框中包含iframe并请求一个新的页面
- Git学习文档之一 学习文档-并行开发
- 回顾JavsScript对象的克隆
- matlab常用函数
- mysql packet_mysql配置: max_allowed_packet
- Intent.ACTION_VIEW
- 【Day4.7】错过湄南河夜游,去河畔夜市晚餐
- 长文详解材料阻燃性能试验方法
- 酷冷战神 先手致胜:腾讯ROG游戏手机6为游戏而生
- 加密解密--换行符作祟
- PPT之幻灯片中的大纲选项卡
- 【前端期末作业 基于jQuery鲜花销售管理系统】
- Android驱动-霍尔摁键hall_sensor的实现
- Python应用开发
- 源码分析 - Spring Security OAuth2 生成 token 的执行流程
- Dos命令简单操作入门操作
热门文章
- 用java写了一个计算器(两个数的加减乘除运算)
- 首播过亿,火爆全网,我分析了《乘风破浪的姐姐》,发现了这些秘密
- GeoServer导入ArcGIS的shp文件样式丢失:自定义Style
- Windows 7 无法登陆网银
- 统计数据库下每张表的数据量
- 《Dokcer的使用》(三) 镜像仓库和镜像
- 网络安全的行业黑话 ——攻击篇 之攻击者
- php自定义json字符串,php自定义json_encode()和json_decode()函数
- CSS阴影样式大全(包含所有样式: demo代码全)看图看代码
- 物联网 实验2 Mind+ 掌控板