gpt4 book ai didi

java - exec-maven-plugin 错误...可以编译,但无法运行项目

转载 作者:行者123 更新时间:2023-12-01 11:25:29 24 4
gpt4 key购买 nike

我先在这里问过...但没有得出结论。请先看看这篇文章。

exec-maven-plugin error, even on working example


===现状===

  1. 我修改了强行固定的 JDK 路径,用于 eclipse java 构建路径和项目构建路径。
  2. 我现在可以编译了。 (使用“mvn -ecompile exec:java”)
  3. 但我跑不了。 (使用“mvn -e clean exec:java”)Maven 找不到我的 mainClass
  4. 我尝试使用“mvn -e clean exec:java -Dexec.mainClass=com.jadex.qna.MavenTestProject.App”显式声明我的主类。但它给了我同样的错误结果。

===数据===

这是我的完整代码(包括pom.xml,你可以用eclipse打开项目)

https://github.com/arincblossom/MavenTestProject

这是我使用“mvn -e clean exec:java”运行项目时显示的错误日志(与上一篇文章中的 EDIT5 相同)

[WARNING] 
[WARNING] Some problems were encountered while building the effective settings
[WARNING] expected START_TAG or END_TAG not TEXT (position: TEXT seen ...ore artifacts.\n |\n | Default: ${user.home}/.m2/repository\n <l... @53:5) @ C:\apache-maven-3.3.3\conf\settings.xml, line 53, column 5
[WARNING] expected START_TAG or END_TAG not TEXT (position: TEXT seen ...ore artifacts.\n |\n | Default: ${user.home}/.m2/repository\n <l... @53:5) @ C:\apache-maven-3.3.3\conf\settings.xml, line 53, column 5
[WARNING]
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building MavenTestProject 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ MavenTestProject ---
[INFO] Deleting C:\Users\bonavision_laptop\Desktop\Project\JadeX\MavenTestProject\MavenTestProject\target
[INFO]
[INFO] --- exec-maven-plugin:1.4.0:java (default-cli) @ MavenTestProject ---
[WARNING]
java.lang.ClassNotFoundException: com.jadex.qna.MavenTestProject.App
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
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:745)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.900 s
[INFO] Finished at: 2015-06-15T17:42:19+09:00
[INFO] Final Memory: 8M/153M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.4.0:java (default-cli) on project MavenTestProject: An exception occured while executing the Java class. com.jadex.qna.MavenTestProject.App -> [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



有什么办法可以解决吗?我已经被困在这个问题里四天了...请帮忙T_T

最佳答案

如果运行mvn clean exec:java,所有已编译的类都会被clean删除,因此exec:java无法找到要执行的类。

如果您运行mvn cleancompile exec:javaclean 删除以前的版本中可能存在的所有已编译类。 compile编译所有源代码并exec:java执行指定的类。

如果输出不是您所期望的,也许您应该更好地描述您想要实现的目标。

输出

[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building MavenTestProject 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ MavenTestProject ---
[INFO] Deleting /tmp/MavenTestProject/target
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ MavenTestProject ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /tmp/MavenTestProject/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ MavenTestProject ---
[INFO] Compiling 1 source file to /tmp/MavenTestProject/target/classes
[INFO]
[INFO] --- exec-maven-plugin:1.4.0:java (default-cli) @ MavenTestProject ---
Hello World!?
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.934s
[INFO] Finished at: Mon Jun 15 12:08:36 CEST 2015
[INFO] Final Memory: 8M/19M
[INFO] ------------------------------------------------------------------------

关于java - exec-maven-plugin 错误...可以编译,但无法运行项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30841617/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com