【问题标题】:Could not find goal 'java-Dexec.mainClass=com.mystique.application.Main_Runner' | Jenkins找不到目标'java-Dexec.mainClass=com.mystique.application.Main_Runner' |詹金斯
【发布时间】:2020-04-01 13:25:41
【问题描述】:

尝试通过 2 个构建步骤在 Jenkins 中构建和运行我的本地 Cucumber 项目。 1st step 成功 clean install,但 2nd steps (exec:java-Dexec.mainClass="com.mystique.application.Main_Runner") 抛出附加错误。

日志:

Building in workspace C:\Users\807240\.jenkins\workspace\Cucumber
[Cucumber] $ cmd.exe /C "C:\Soumen\Softwares\apache-maven-3.6.1\bin\mvn.cmd -f C:/Soumen/Cucumber_WorkspacePhoton/Cucumber/pom.xml -s C:\Soumen\Softwares\apache-maven-3.6.1\conf\settings.xml -gs C:\Soumen\Softwares\apache-maven-3.6.1\conf\settings.xml clean install && exit %%ERRORLEVEL%%"
[INFO] Scanning for projects...
[INFO] 
[INFO] ----------------< com.opencredo:cucumber-jvm-parallel >-----------------
[INFO] Building cucumber-jvm-parallel 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[WARNING] The POM for info.cukes:cucumber-java:jar:1.2.3 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for org.apache.directory.studio:org.apache.commons.codec:jar:1.8 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for org.yaml:snakeyaml:jar:1.8 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The artifact junit:junit-dep:jar:4.11 has been relocated to junit:junit:jar:4.11
[WARNING] The artifact org.apache.commons:commons-io:jar:1.3.2 has been relocated to commons-io:commons-io:jar:1.3.2
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ cucumber-jvm-parallel ---
[INFO] Deleting C:\Soumen\Cucumber_WorkspacePhoton\Cucumber\target
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ cucumber-jvm-parallel ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Soumen\Cucumber_WorkspacePhoton\Cucumber\src\main\resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ cucumber-jvm-parallel ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ cucumber-jvm-parallel ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 1 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ cucumber-jvm-parallel ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 101 source files to C:\Soumen\Cucumber_WorkspacePhoton\Cucumber\target\test-classes
[WARNING] /C:/Soumen/Cucumber_WorkspacePhoton/Cucumber/src/test/java/com/mystique/roomsteps/RunTests.java: Some input files use unchecked or unsafe operations.
[WARNING] /C:/Soumen/Cucumber_WorkspacePhoton/Cucumber/src/test/java/com/mystique/roomsteps/RunTests.java: Recompile with -Xlint:unchecked for details.
[INFO] 
[INFO] --- maven-surefire-plugin:2.19:test (default-test) @ cucumber-jvm-parallel ---
[INFO] 
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ cucumber-jvm-parallel ---
[WARNING] JAR will be empty - no content was marked for inclusion!
[INFO] Building jar: C:\Soumen\Cucumber_WorkspacePhoton\Cucumber\target\cucumber-jvm-parallel-1.0-SNAPSHOT.jar
[INFO] 
[INFO] --- maven-install-plugin:2.4:install (default-install) @ cucumber-jvm-parallel ---
[INFO] Installing C:\Soumen\Cucumber_WorkspacePhoton\Cucumber\target\cucumber-jvm-parallel-1.0-SNAPSHOT.jar to C:\Soumen\MavenRepo\com\opencredo\cucumber-jvm-parallel\1.0-SNAPSHOT\cucumber-jvm-parallel-1.0-SNAPSHOT.jar
[INFO] Installing C:\Soumen\Cucumber_WorkspacePhoton\Cucumber\pom.xml to C:\Soumen\MavenRepo\com\opencredo\cucumber-jvm-parallel\1.0-SNAPSHOT\cucumber-jvm-parallel-1.0-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  12.053 s
[INFO] Finished at: 2020-04-01T18:36:10+05:30
[INFO] ------------------------------------------------------------------------
[Cucumber] $ cmd.exe /C "C:\Soumen\Softwares\apache-maven-3.6.1\bin\mvn.cmd -f C:/Soumen/Cucumber_WorkspacePhoton/Cucumber/pom.xml -s C:\Soumen\Softwares\apache-maven-3.6.1\conf\settings.xml -gs C:\Soumen\Softwares\apache-maven-3.6.1\conf\settings.xml exec:java-Dexec.mainClass=com.mystique.application.Main_Runner && exit %%ERRORLEVEL%%"
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.496 s
[INFO] Finished at: 2020-04-01T18:36:16+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Could not find goal 'java-Dexec.mainClass=com.mystique.application.Main_Runner' in plugin org.codehaus.mojo:exec-maven-plugin:1.5.0 among available goals exec, help, java -> [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/MojoNotFoundException
Build step 'Invoke top-level Maven targets' marked build as failure
Finished: FAILURE

【问题讨论】:

  • 第二份工作的目标是什么?只需确保已安装的 jar 部署在正确的文件夹中即可执行作业。
  • 目标是 exec:java -Dexec.mainClass="com.mystique.application.Main_Runner"
  • [INFO] --- exec-maven-plugin:1.5.0:java (default-cli) @ cucumber-jvm-parallel --- [警告] java.lang.ClassNotFoundException: com. mystique.application.Main_Runner at java.net.URLClassLoader.findClass (URLClassLoader.java:382) at java.lang.ClassLoader.loadClass (ClassLoader.java:424) at java.lang.ClassLoader.loadClass (ClassLoader.java:357)在 org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:281) 在 java.lang.Thread.run (Thread.java:748) [INFO] ------------ -------------------------------------------------- ---------- [信息] 构建失败
  • 你能告诉我是否需要为这个错误下载任何特定的 jar 吗? [错误] 无法在项目 cucumber-jvm-parallel 上执行目标 org.codehaus.mojo:exec-maven-plugin:1.5.0:java (default-cli):执行 Java 类时发生异常。 com.mystique.application.Main_Runner ->

标签: jenkins selenium-webdriver cucumber


【解决方案1】:

你错过了 exec:java 和 -Dexec.mainClass="com.mystique.application.Main_Runner" 之间的空格

【讨论】:

  • 现在我遇到了错误。 [警告] java.lang.ClassNotFoundException: com.mystique.application.Main_Runner at java.net.URLClassLoader.findClass (URLClassLoader.java:382) at java.lang.ClassLoader.loadClass (ClassLoader.java:424) at java.lang .ClassLoader.loadClass (ClassLoader.java:357) at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:281) at java.lang.Thread.run (Thread.java:748) [INFO] - -------------------------------------------------- --------------------- [信息] 构建失败
  • [ERROR] 无法在项目 cucumber-jvm-parallel 上执行目标 org.codehaus.mojo:exec-maven-plugin:1.5.0:java (default-cli):执行时发生异常Java 类。 com.mystique.application.Main_Runner -> [帮助 1]
  • 您是否尝试一次性使用“clean install exec:java...”进行一次 maven 调用?
  • 还要确保你的类 com.mystique.application.Main_Runner 位于 src/main/java,而不是 src/test/java。并且您确实在目标/类(或测试类)中找到 Main_Runner.class。如果它在测试类中,请将其添加到您的选项中:-Dexec.classpathScope=test
  • 是的,它在测试类中,所以目标应该是 exec:java -Dexec.classpathScope="com.mystique.application.Main_Runner" ,如果我错了,请纠正我。
猜你喜欢
  • 2012-09-30
  • 2014-07-24
  • 2018-02-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多