JMH 无法找到资源:/META-INF/BenchmarkList
我无法在 eclipse 中运行简单的 JMH 基准测试。Maven dependencies:
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-core</artifactId>
<version>1.12</version>
</dependency>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-generator-annprocess</artifactId>
<version>1.12</version>
</dependency>
Java 代码:
public class BTest {
@Benchmark
public void test() {
// todo
}
public static void main(String[] args) throws RunnerException {
Options opt = new OptionsBuilder()
.include(BTest.class.getSimpleName())
.build();
new Runner(opt).run();
}
}
运行结果:
线程“main” java.lang.RuntimeException 中的异常: 错误: 无法找到资源: /META-INF/BenchmarkList at org.openjdk.jmh.runner.AbstractResourceReader.getReaders(AbstractResourceReader.java:96) at org.openjdk.jmh.runner.BenchmarkList.find(BenchmarkList.java:104) at org.openjdk.jmh.runner.internalRun(Runner.java:256) at org.openjdk.jmh.runner.run(Runner.java:206) at com.test.BTest.main(BTest.java:24)
也许问题是,我正在从日食运行它。