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

Microbenchmark基准测试出现异常提示:Unable to find the resource: /META-INF/BenchmarkList。

META-INF目录下未包含BenchmarkList文件。

通常分两种情况:

1、IDE中直接运行则可能是未进行编译引起,确保所有的依赖项配置正确,运行打包命令或者编译。

2、正确配置依赖项,以maven为例:

<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插件。