java - 使用 exec Maven 插件的java井徑測試說明main方法簽名無效

  显示原文与译文双语对照的内容
62 1

我正在試圖使用 Maven 工作的卡卡卡,我還沒有成功地運行一個卡卡基測試測試。

卡尺版本:1.0 -beta-1

我的基準測試:

public class MyXercesSAXHandlerBenchmark extends Benchmark{
 @Param({"10","100","1000","10000"}) private int length;
 public void timeNanoTime(int reps) {
 for (int i = 0; i <reps; i++) {
 System.nanoTime();
 }
 }
 public static void main(String[] args) {
 CaliperMain.main(MyXercesSAXHandlerBenchmark.class, args);
 }
}

我的Maven pom.xml 有:

<profiles>
 <profile>
 <id>benchmarks</id>
 <build>
 <plugins>
 <plugin>
 <groupId>org.codehaus.mojo</groupId>
 <artifactId>exec-maven-plugin</artifactId>
 <version>1.1</version>
 <executions>
 <execution>
 <id>caliper</id>
 <phase>compile</phase>
 <goals>
 <goal>java</goal>
 </goals>
 <configuration>
 <classpathScope>test</classpathScope>
 <mainClass>my.path.to.benchmark.MyXercesSAXHandlerBenchmark</mainClass>
 <arguments>
 </arguments>
 </configuration>
 </execution>
 </executions>
 </plugin>
 </plugins>
 </build>
 </profile>
</profiles>

我運行了:

mvn clean安裝mvn編譯-P編譯基準 -e -X

Caused by: org.apache.maven.plugin.MojoExecutionException: An exception occured while executing the Java class. The specified mainClass doesn't contain a main method with appropriate signature.
 at org.codehaus.mojo.exec.ExecJavaMojo.execute(ExecJavaMojo.java:345)
 at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
 at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
. . . 19 more
Caused by: java.lang.Exception: The specified mainClass doesn't contain a main method with appropriate signature.
 at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:294)
 at java.lang.Thread.run(Thread.java:680)
Caused by: java.lang.NoSuchMethodException: com.google.caliper.runner.CaliperMain.main([Ljava.lang.String;)
 at java.lang.Class.getMethod(Class.java:1632)
 at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:283)
. . . 1 more
时间:原作者:0个回答

...