我正在使用黃瓜框架進行移動應用程式測驗。在 pom.xml 中,我提供了以下插件來運行 TestClass.java - 它具有用于上傳應用程式的最新 apk 版本的代碼。此 TestClass 中存在 Main 方法。我需要在實際測驗執行之前運行它。所以使用了 exec 插件。如果我使用 pom.xml --> mvn clean test 運行,我會收到這個錯誤。ClassNotFoundExpection 總是與 pom.xml 一起拋出,但單個類運行完美。
pom.xml:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>installAPK</id>
<phase>generate-test-sources</phase>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<includePluginDependencies>true</includePluginDependencies>
<mainClass>org.com.package1.TestClass</mainClass>
</configuration>
</plugin>
Console error:
java.lang.ClassNotFoundException: org.com.package1.TestClass
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:246)
at java.lang.Thread.run(Thread.java:748)
I also tried changing the phase after test-compile. Still i am getting the same error. Someone pls help.
uj5u.com熱心網友回復:
根據exec-maven-plugin 檔案,執行的默認依賴范圍是runtime. test如果TestClass是測驗源的一部分,請將其更改為以下配置。
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
...
</executions>
<configuration>
...
<classpathScope>test</classpathScope>
</configuration>
</plugin>
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/326989.html
標籤:爪哇 行家 pom.xml 黄瓜-java maven-exec-plugin
上一篇:在PHP中顯示表格
下一篇:通過完全限定的包名稱指定測驗集
