exec-maven-plugin错误,即使在工作示例中 [英] exec-maven-plugin error, even on working example
问题描述
EDIT5已更新/
我正在使用Maven 3.3.3.
我只是创建一个新项目,并添加了compile和exec插件,例如在Web上.
我尝试执行,但出现错误
I'm using Maven 3.3.3.
I just create new project and added compile and exec plugin, as examples on web.
I tried to execute, but I got error
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:java (default-cli) on project QNAProject: An exception occured while executing the Java class. com.jadex.qna.QNAProject.App -> [Help 1]<br>
[ERROR] <br>
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.<br>
[ERROR] Re-run Maven using the -X switch to enable full debug logging.<br>
[ERROR] <br>
[ERROR] For more information about the errors and possible solutions, please read the following articles:<br>
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException<br>
我尝试了exec-maven-plugin版本1.2.1和1.4.0,但是遇到了相同的错误.这是我的pom.xml
I tried exec-maven-plugin version 1.2.1 and 1.4.0, but got same error. Here is my pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.jadex.qna</groupId>
<artifactId>QNAProject</artifactId>
<version>0.1</version>
<packaging>jar</packaging>
<name>QNAProject</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>maven</executable>
<mainClass>com.jadex.qna.QNAProject.App</mainClass>
</configuration>
</plugin>
</plugins>
</build>
</project>
我什至从多个站点尝试了一个可行的示例项目,
例如
I even tried a working example project from several sites,
such as
http://examples. javacodegeeks.com/enterprise-java/maven/create-java-project-with-maven-example/
http://www.mkyong.com /maven/how-to-to-create-a-java-project-with-maven/
http://examples.javacodegeeks.com/enterprise-java/maven/create-java-project-with-maven-example/
http://www.mkyong.com/maven/how-to-create-a-java-project-with-maven/
但是我遇到了同样的错误.
but I got same error.
我在C:\ apache-maven-3.3.3解压缩了Maven,并创建了环境变量MAVEN_HOME作为同一路径. 有什么问题吗?
I unzipped maven at C:\apache-maven-3.3.3 and created environment variable MAVEN_HOME as same path. What is the problem?
==================================
====================================
这是结果
好吧.我设置了MAVEN_HOME,而不是M2_HOME,因为我发现本教程中所说的仅设置它...
当然,回声%MAVEN_HOME%显示了
Well.. I set MAVEN_HOME, not M2_HOME because tutorial what I found said to set it only...
Of course, echo %MAVEN_HOME% shows
C:\ apache-maven-3.3.3
C:\apache-maven-3.3.3
错了吗?
我将%MAVEN_HOME%\ bin添加到PATH变量,但是它也无法正常工作.
而且,我正在使用eclipse
I added %MAVEN_HOME%\bin to PATH variable, but it did not work too.
And, I'm using eclipse
====================================
=====================================
这是完整的日志.我用了目标'clean exec:java -e -X'
Here is full log. I used goal 'clean exec:java -e -X'
时间太长,所以我在这里上传到了我的博客.
并注意,我将存储库文件夹从C:\ Users ..... m2更改为新的本地存储库文件夹C:\ apache-maven-localrepository
It was too long, so I uploaded to my blog here.
And note that I changed repository folder from C:\Users.....m2 to new local repository folder C:\apache-maven-localrepository
=====================================
=======================================
我这样更改了maven-compiler-plugin设置
I changed maven-compiler-plugin setting like this
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<verbose>true</verbose>
<fork>true</fork>
<executable>${env.JAVA_HOME}/bin/javac</executable>
<compilerVersion>1.5</compilerVersion>
<!-- <source>1.8</source>
<target>1.8</target> -->
</configuration>
</plugin>
它防止了mvn -e compile exec:java
的错误,但我无法使用mvn exec:java -Dexec.mainClass="com.jadex.qna.QNAProject.App"
It prevented me from having error from mvn -e compile exec:java
but I can't run with mvn exec:java -Dexec.mainClass="com.jadex.qna.QNAProject.App"
================================
=================================
好的,我会从底部尝试,然后再次发布.感谢您的真诚帮助.
OK, I'll try from the bottom, and post again. Thanks for your sincere helps.
====================================
======================================
EDIT5
我重置了所有序列...重新安装了eclipse,maven ..和重新创建的项目...但是没有任何作用...
I reset all the sequences... re-installed eclipse, maven.. and re-created projects... but nothing worked...
我更改了Eclipse设置,以将JDK路径固定为已安装的jdk路径,而不是JRE路径.然后我发现"mvn -e clean exec:java"正在工作,但是我只想"mvn clean exec:java"在工作.它根本不起作用.
I changed eclipse settings to fix JDK path to installed jdk path, not JRE path. then I found that 'mvn -e clean compile exec:java' is working, but I want to just 'mvn clean exec:java' work. It does not work at all.
您可以在此处查看完整的源代码
You can check full source here
这是'mvn -e clean exec:java'的当前控制台消息
This is current console message for 'mvn -e clean exec:java'
[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
推荐答案
您发布的错误日志显示以下内容:
The error log which you posted says the following:
java.lang.ClassNotFoundException com.jadex.qna.QNAProject.App
因此,可以清楚该错误的根源是什么.您试图执行其类文件Maven找不到的类的main()
方法.正如这篇SO文章所述,您可以先尝试进行显式编译,然后在生成类文件后执行:
So it clear what the root source of the error is. You are trying to execute the main()
method of a class whose class file Maven cannot find. As this SO article discusses, you can try explicitly compiling first, then executing after the class file has been generated:
mvn -e compile exec:java
mvn exec:java -Dexec.mainClass="com.jadex.qna.QNAProject.App"
这篇关于exec-maven-plugin错误,即使在工作示例中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!