JMH不在Java模块内运行(无法找到资源:/META-INF/BenchmarkList) [英] JMH doesn't run inside a Java Module (Unable to find the resource: /META-INF/BenchmarkList)

查看:952
本文介绍了JMH不在Java模块内运行(无法找到资源:/META-INF/BenchmarkList)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我参加了一个使用maven-surefire-plugin(自动测试)来触发JMH基准测试的项目,并在其中添加了module-info.java.现在,META-INF/BenchmarkList不再生成(实际上,整个目录都丢失了),因此在启动基准测试时我遇到了以下错误:

I took a project that uses maven-surefire-plugin (automated tests) to trigger JMH benchmarks and added module-info.java to it. Now, META-INF/BenchmarkList is no longer getting generated (in fact, the entire directory is missing) so I end up with the following error when launching the benchmarks:

ERROR: Unable to find the resource: /META-INF/BenchmarkList

我怀疑Java模块正在阻止注释处理器正常运行,但是我不知道如何解决它.有什么想法吗?

I suspect that Java Modules is preventing the annotation processor from running properly, but I can't figure out how to fix it. Any ideas?

推荐答案

我通过反复试验弄清楚了这一点.它看起来像是maven-compiler-plugin 3.8.0中的错误(或功能").如果存在module-info.java,将不再自动拾取JMH注释处理器.添加此配置可以解决我的问题:

I figured it out through trial and error. It looks like a bug (or "feature") in maven-compiler-plugin 3.8.0. When module-info.java is present, the JMH annotation processor is no longer picked up automatically. Adding this configuration fixed the problem for me:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
    [...]
        <annotationProcessorPaths>
            <path>
                <groupId>org.openjdk.jmh</groupId>
                <artifactId>jmh-generator-annprocess</artifactId>
                <version>${jmh.version}</version>
            </path>
        </annotationProcessorPaths>
    [...]
    </configuration>
</plugin>

更新:我提交了错误报告反对maven-compiler-plugin.

UPDATE: I filed a bug report against maven-compiler-plugin.

这篇关于JMH不在Java模块内运行(无法找到资源:/META-INF/BenchmarkList)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆