无法执行目标org.codehaus.mojo:exec-maven-plugin:1.6.0:java [英] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0:java

查看:363
本文介绍了无法执行目标org.codehaus.mojo:exec-maven-plugin:1.6.0:java的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过使用 Maven Run Configurations 中的以下命令,使用pom.xml文件执行testNG主类.

I am trying to execute the testNG main class using pom.xml file by using the below command in Maven Run Configurations.

exec:java -Dexec.mainClass=com.selenium.controls.TestNGMainClass

在这里,我正在使用 Java 8 .

但是我遇到了以下错误.

But I got the below error.

[INFO] ------------------------------------------------------------------------
[INFO] Building seleniumScriptsRegression 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- exec-maven-plugin:1.6.0:java (default-cli) @ seleniumScriptsRegression ---
[WARNING] java.lang.ClassNotFoundException: com.selenium.controls.TestNGMainClass
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:270)
at java.lang.Thread.run(Unknown Source)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.331 s
[INFO] Finished at: 2018-01-29T10:59:54+05:30
[INFO] Final Memory: 13M/32M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0:java (default-cli) on project seleniumScriptsRegression: An exception occured while executing the Java class. com.selenium.controls.TestNGMainClass -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

请帮助我解决此问题.

推荐答案

假设您在src/test/java中拥有Main.java

Assuming you have a Main.java in src/test/java

将此添加到您的pom.xml

Add this in your pom.xml

 <build>
            <plugins>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>exec-maven-plugin</artifactId>
                    <version>1.6.0</version>
                    <configuration>
                        <classpathScope>test</classpathScope>
                        <mainClass>Main</mainClass>
                    </configuration>
                    <executions>
                        <execution>
                            <id>run-selenium</id>
                            <phase>integration-test</phase>
                            <goals><goal>java</goal></goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>

并通过:

mvn clean installmvn exec:java

这篇关于无法执行目标org.codehaus.mojo:exec-maven-plugin:1.6.0:java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆