pom.xml文件中导入Reflections架包
<!--使用 Reflections 可以查询以下元数据信息:
1)获得某个类型的所有子类型
2)获得标记了某个注解的所有类型/成员变量,支持注解参数匹配。
3)使用正则表达式获得所有匹配的资源文件
4)获得所有特定签名(包括参数,参数注解,返回值)的方法-->
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.9.10</version>
</dependency>
Reflections reflections = new Reflections("com.zgf.annotation");
Set<Class<?>> typesAnnotatedWith = reflections.getTypesAnnotatedWith(DataClass.class);
for (Class c:typesAnnotatedWith){
System.out.println(c.getName());
}