java - org.reflections:reflections:0.10.2 getConstructorsAnnotatedWIth 返回一个空集
问题描述
我试图从 0.9.12 更新到 0.10.2,但是当我这样做时,getConstructorsAnnotatedWith() 返回一个空集。
仅仅恢复到 0.9.12 就可以解决问题,但我想运行最新最好的版本。
我正在使用 gmavenplus 插件在编译时生成反射.xml 文件,那里没有任何改变:
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>execute</goal>
</goals>
</execution>
</executions>
<configuration>
<scripts>
<script><![CDATA[
new org.reflections.Reflections(
"com.walterjwhite",
org.reflections.scanners.TypeAnnotationsScanner.class,
org.reflections.scanners.SubTypesScanner.class,
org.reflections.scanners.FieldAnnotationsScanner.class,
org.reflections.scanners.ResourcesScanner.class,
org.reflections.scanners.MethodAnnotationsScanner.class
)
.save("${project.build.outputDirectory}/META-INF/reflections/${project.groupId}-${project.artifactId}-reflections.xml")
]]></script>
</scripts>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.4.12</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.9.12</version>
</dependency>
<!-- When writing XML, this is required -->
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.6.1</version>
</dependency>
</dependencies>
</plugin>
返回空集的代码:
Reflections.collect().getConstructorsAnnotatedWith(Inject.class)
对应的依赖:
<dependencies>
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.9.12</version>
</dependency>
<!-- When writing XML, this is required -->
<dependency>
<groupId>org.dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>2.1.3</version>
</dependency>
</dependencies>
解决方案
推荐阅读
- python - 页面将继续使用 {%endfor%} 出现 404 错误,但如果删除将呈现,但现在将显示帖子
- artifactory - jFrog神器OSS开源支持多LDAP?
- string - 在 AppleMail applescript 中获取规则列表
- javascript - Ant Design modal在react js中出现几次
- python - 如何从多个 websocket 流中提取数据以在公式中使用?
- reactjs - 前端应用程序需要多少数据(输入)验证?
- ios - 如何在 React Native App 中使用 Styled Components 将图像放置在另一个图像之上
- angular - 无法将类型分配给角度字符串
- json - Jmeter仅提取方括号内的值
- c# - 我如何将地址返回到字节 [] 偏移量