我收到此错误,我真的不知道为什么,在我使用它的几天里它仍然可以正常工作,然后今天当我去使用它时(什么也没改变)它就停止工作了……?< / p>
java.lang.NoSuchMethodError: com.google.common.collect.Sets$SetView.iterator()Lcom/google/common/collect/UnmodifiableIterator;
at org.reflections.Reflections.expandSuperTypes(Reflections.java:380) ~[?:?]
at org.reflections.Reflections.<init>(Reflections.java:126) ~[?:?]
at org.reflections.Reflections.<init>(Reflections.java:168) ~[?:?]
at org.reflections.Reflections.<init>(Reflections.java:141) ~[?:?]
at me.realm.commons.reflection.Reflect.getClassesExtending(Reflect.java:14) ~[?:?]
我的maven依赖项(并且已将其包含在项目构建路径中)
<dependencies>
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.9.11</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.8.1</version>
</dependency>
</dependencies>
抛出错误的代码:
public static <T> Set<Class<? extends T>> getClassesExtending(Class<T> clazz) {
Reflections reflections = new Reflections(""); //<-- this line
Set<Class<? extends T>> classes = reflections.getSubTypesOf(clazz);
if (classes.size() <= 0) {
Logger.warn("No classes extending " + clazz.getCanonicalName());
return classes;
}
return classes;
}