JMH无法找到资源:/ META-INF / BenchmarkList

我无法在Eclipse中运行简单的JMH基准测试。Maven依赖项:

        <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>

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();

}

}

线程“主”中的异常java.lang.RuntimeException:错误:无法找到资源:org.openjdk上的org.openjdk.jmh.runner.AbstractResourceReader.getReaders(AbstractResourceReader.java:96)上的/

META-INF /

BenchmarkList。在org.openjdk.jmh.runner.Runner.Runner.internalRun(Runner.java:256)在org.openjdk.jmh.runner.Runner.run(Runner.java:的jmh.runner.BenchmarkList.find(BenchmarkList.java:104)

206),位于com.test.BTest.main(BTest.java:24)

也许问题是,我是从Eclipse运行它。

回答:

终于发现了。缺少exec-maven-plugin插件存在问题

<plugin>

<groupId>org.codehaus.mojo</groupId>

<artifactId>exec-maven-plugin</artifactId>

<executions>

<execution>

<id>run-benchmarks</id>

<phase>integration-test</phase>

<goals>

<goal>exec</goal>

</goals>

<configuration>

<classpathScope>test</classpathScope>

<executable>java</executable>

<arguments>

<argument>-classpath</argument>

<classpath />

<argument>org.openjdk.jmh.Main</argument>

<argument>.*</argument>

</arguments>

</configuration>

</execution>

</executions>

</plugin>

以上是 JMH无法找到资源:/ META-INF / BenchmarkList 的全部内容, 来源链接: utcz.com/qa/423032.html

回到顶部