exec-maven-plugin错误...可以编译,但不能运行项目

时间:2015-06-15 09:24:12

标签: java eclipse maven

我先问到这里......但没有结束。请先看看这篇文章。

  

exec-maven-plugin error, even on working example


===现状===

  1. 我为eclipse java构建路径和项目构建路径强制修改了JDK路径。
  2. 我现在可以编译了。 (使用' mvn -e compile exec:java')
  3. 但我不能跑。 (使用' mvn -e clean exec:java')Maven找不到我的mainClass
  4. 我尝试用' mvn -e clean exec:java -Dexec.mainClass=com.jadex.qna.MavenTestProject.App'明确宣布我的主要课程。但它给我同样的错误结果。

  5. ===数据===

    这是我的完整代码(包括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
    



    有什么办法可以解决吗?我现在已经坚持了4天......请帮助T_T

1 个答案:

答案 0 :(得分:1)

如果您运行clean exec:java删除了所有已编译的类,那么mvn clean compile exec:java无法找到要执行的类。

如果您运行cleancompile删除所有已编译的类,这些类可能来自之前的biuld。 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] ------------------------------------------------------------------------ 执行指定的类。

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

<强>输出

getInstance()