问题描述
我正在使用 Reflections library 来获取由特定包中的特定注释注释的所有类。
IndexSpec 注释
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface IndexSpec {
String value();
}
带注释的类
@IndexSpec("connected_clients")
public class ConnectedClients implements ElasticIndex {
[...]
}
反思
[...]
var reflections = new Reflections(new ConfigurationBuilder()
.setUrls(ClasspathHelper.forPackage("a.b.c.indices")) // Package name redacted for legal reasons
.setScanners(new SubTypesScanner(),new TypeAnnotationsScanner()));
var annotatedindices = reflections.getTypesAnnotatedWith(IndexSpec.class);
[...]
这段代码工作正常,但我收到了大量警告。许多不同的、不相关的类有几百个。
Reflections 说它在一个包含两个类的包中发现了很多类。
Reflections took 2303 ms to scan 1 urls,producing 2898 keys and 11715 values
所有的警告都是这样的:
[org.reflections.Reflections] Could not get type for name com.fasterxml.jackson.databind.ObjectMapper from any class loader
为什么库扫描的类与它配置的包不同?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)