Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/308.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java反射:获取类而不是子类型_Java_Reflection - Fatal编程技术网

Java反射:获取类而不是子类型

Java反射:获取类而不是子类型,java,reflection,Java,Reflection,我正在从org.reflections:reflections:0.9.5升级到0.9.9版。我正在使用: Reflections reflectionPaths = new Reflections("resources", new TypeAnnotationsScanner()); Set<Class<?>> rootResourceClasses = reflectionPaths.getTypesAnnotatedWith(Path.class); 我相信您正在

我正在从org.reflections:reflections:0.9.5升级到0.9.9版。我正在使用:

Reflections reflectionPaths = new Reflections("resources", new TypeAnnotationsScanner());
Set<Class<?>> rootResourceClasses = reflectionPaths.getTypesAnnotatedWith(Path.class);

我相信您正在使用这个注释“javax.ws.rs.Path”。请试试这个:-

Reflections reflectionPaths = new Reflections("resources", new TypeAnnotationsScanner());
Set<Class<?>> rootResourceClasses = reflectionPaths.getTypesAnnotatedWith(Path.class, true);
reflectionpath=新反射(“资源”,新类型annotationsscanner());

Set不确定是否有帮助,但当我更新一个完全不相关的库时,出现了
扫描仪子系统扫描仪未配置
错误

我发现有人在查找类似的错误时发现,当路径完全为空时(不是我的情况)会引发异常,但如果所查找的基类不在扫描包中(我的情况),也会引发异常


我不知道它为什么会工作,也不知道它为什么会停止,但我在扫描仪中添加了丢失的包,它又开始工作了。

这对我来说不起作用:(我仍然得到同样的错误。奇怪的是,我得到了
typeannotationsCanner()
已经存在了。知道它为什么会失败吗?@xbmono在该主题上成功了吗?我也有同样的问题,scanner在构造函数中通过了,并告诉我不是configured@HenningLuther很抱歉,这是很久以前的事了,我真的不记得我做了什么,但在我的情况下,相同的代码工作得很好(不确定这是否是jdk中的一个bug,我们升级了它或其他东西),但这段代码运行良好:
Reflections Reflections=newreflections(新字符串[]{“com.mypackage”})
@xbmono-thx寻求答案。似乎我在使用java13时遇到了这个问题。不知何故,从8升级到13后,反射不起作用。所以我只是等待他们为13提供修复
Reflections reflectionPaths = new Reflections("resources", new TypeAnnotationsScanner());
Set<Class<?>> rootResourceClasses = reflectionPaths.getTypesAnnotatedWith(Path.class, true);