簡體   English   中英

無法執行目標org.codehaus.mojo:exec-maven-plugin:1.6.0:java

[英]Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0:java

我正在嘗試使用pom.xml文件在Maven運行配置中使用以下命令來執行testNG主類。

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

在這里,我使用的是Java 8

但我得到了以下錯誤。

[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

請幫我解決這個問題。

你可以嘗試在沒有你的ide(eclipse)的情況下執行它嗎? 你可以分享你在maven目標文件夾中找到主類的位置嗎?

假設你在src / test / java中有一個Main.java

在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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM