1. Gradle
如果是gradle项目, 在build.gradle文件中添加jmh的依赖 (有梯子好办事)
plugins {
id 'java'
}
allprojects {
repositories {
maven { url 'https://maven.aliyun.com/repository/jcenter' }
maven { url 'https://maven.aliyun.com/repository/google' }
maven { url 'https://maven.aliyun.com/repository/central' }
maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
}
}
dependencies {
implementation 'org.openjdk.jmh:jmh-core:1.33'
annotationProcessor 'org.openjdk.jmh:jmh-generator-annprocess:1.33'
}
2. Maven
如果你的项目是maven项目,直接添加依赖
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-core</artifactId>
<version>1.33</version>
</dependency>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-generator-annprocess</artifactId>
<version>1.33</version>
<scope>provided</scope>
</dependency>