使用exec-maven-plugin的卡尺测试表明主方法签名无效 [英] Caliper test using exec-maven-plugin is saying main method signature isn't valid
本文介绍了使用exec-maven-plugin的卡尺测试表明主方法签名无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试让Caliper与maven一起使用,但到目前为止我还没有成功运行过Caliper基准测试.
I'm trying to get Caliper working with maven, I haven't successfully ran a caliper benchmark test as of yet.
卡尺版本:1.0-beta-1
Caliper version: 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具有:
My maven pom.xml has:
<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全新安装 mvn编译-P基准-e -X
mvn clean install mvn compile -P benchmarks -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
推荐答案
maven-exec-plugin
与1.0-beta-1
不兼容.当然,您需要从6d05814727e8b119651247952dedf4ab321d890a
-HEAD
以后的版本中构建卡尺.
The maven-exec-plugin
doesn't work with 1.0-beta-1
. You need to build caliper from a revision later than 6d05814727e8b119651247952dedf4ab321d890a
- HEAD
, of course, works.
这篇关于使用exec-maven-plugin的卡尺测试表明主方法签名无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文