使用openJDK的Microbenchmark做基准测试,运行测试用例时,出现Unable to find the resource: /META-INF/BenchmarkList。
Unable to find the resource: /META-INF/BenchmarkList
提示表明所打的程序包中,META-INF目录下没有包含BenchmarkList文件。
通常分两种情况:
1、如果是在IDE中直接运行,则可能是没进行编译引起的。确保所有的依赖项都配置正确,然后运行打包命令,或者执行编译操作。
2、正确配置依赖项,以maven项目为例:
--markup--<dependency> <groupId>org.openjdk.jmh</groupId> <artifactId>jmh-core</artifactId> <version>1.11.2</version> </dependency> <dependency> <groupId>org.openjdk.jmh</groupId> <artifactId>jmh-generator-annprocess</artifactId> <version>1.11.2</version> </dependency> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>3.2.1</version> <executions> <execution> <goals> <goal>shade</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build>
如果是spring boot项目则不需要maven-shade-plugin插件。