1、写了一个maven插件收集接口信息,使用Reflection库扫描目标项目中的类信息,在目标项目中传入目标项目待扫描包名,无法生成对应类对象集合?
2、目标项目待扫描包名:com.bigo.studentmanager.controller
public Set<Class<?>> getValidClasses(Class<? extends Annotation> clazz) throws GenerateException {
Set<Class<?>> classes = new LinkedHashSet<Class<?>>();
List<String> prefixes = new ArrayList<String>();
if (getLocations() == null) {
prefixes.add("");
} else {
prefixes.addAll(getLocations());
}
for (String location : prefixes) {
Set<Class<?>> c = new Reflections(location).getTypesAnnotatedWith(clazz, true);
classes.addAll(c);
if (!skipInheritingClasses) {
Set<Class<?>> inherited = new Reflections(location).getTypesAnnotatedWith(clazz);
classes.addAll(inherited);
}
}
3、在插件项目进行单元测试可以解析其下的类包
4、个人猜想是不是插件运行时是不是无法解析jar包外部的包路径生成class对象,有没有精通Reflection库的大佬帮我解决以下这个问题?