如何使用Googlereflection库扫描在运行时加载的JAR?

是否有配置reflection库的解决方案,以便它还扫描在运行时使用URLClassLoader添加的JAR?

现在,reflection只扫描ClassLoader中的URL。 这是我现在使用的配置:

Reflections reflections = new Reflections(new ConfigurationBuilder().setUrls(ClasspathHelper.forClassLoader())); 

我在reflection库的文档中找不到任何提示。

编辑:这是我加载jar文件的方式:

 File f = new File("C:/Users/mkorsch/Desktop/test-reflections.jar"); URLClassLoader urlCl = new URLClassLoader(new URL[] {f.toURI().toURL()},System.class.getClassLoader()); 

也许你需要使用相关的类加载器,

 Reflections reflections = new Reflections(new ConfigurationBuilder().setUrls(ClasspathHelper.forPackage("my.package", myClassLoader)).addClassLoader(myClassLoader)); 

要不就:

 new Reflections("my.package", myClassLoader, scanners, ...) 

在文档中查看。