EDIT5更新/
我正在使用Maven 3.3.3 我只是创建新项目并添加了编译和执行插件,作为网络上的示例 我试图执行,但是我收到了错误
[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
<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>
我甚至尝试了几个站点的工作示例项目,
如
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/
但我得到同样的错误。
我在C:\ apache-maven-3.3.3解压缩maven,并将环境变量MAVEN_HOME创建为相同的路径。 有什么问题?
====================================
编辑:结果如下
嗯..我设置了MAVEN_HOME,而不是M2_HOME,因为教程我发现说只设置它...
当然,echo%MAVEN_HOME%显示
C:\ Apache的行家-3.3.3
是不是错了?
我将%MAVEN_HOME%\ bin添加到PATH变量,但它也不起作用 而且,我正在使用eclipse
=====================================
EDIT2:这是完整的日志。我使用了目标'clean exec:java -e -X'
太长了,所以我在这里上传到了我的博客 请注意,我将存储库文件夹从C:\ Users ..... m2更改为新的本地存储库文件夹C:\ apache-maven-localrepository
=======================================
EDIT3:我改变了像这样的maven-compiler-plugin设置
<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"
=================================
EDIT4:好的,我会从底部尝试,然后重新发布。感谢您的真诚帮助。
======================================
EDIT5
我重置了所有序列......重新安装了eclipse,maven ..并重新创建了项目......但没有任何效果......
我更改了eclipse设置以修复已安装的jdk路径的JDK路径,而不是JRE路径。然后我发现'mvn -e clean compile exec:java'正在工作,但我想只是'mvn clean exec:java'工作。它根本不起作用。
您可以在此处查看完整来源
这是'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
答案 0 :(得分:2)
当问题与eclipse不兼容时,会出现此问题。
试试这个
mvn clean install eclipse:eclipse
投票,如果它可以帮助其他成员
答案 1 :(得分:1)
您发布的错误日志说明如下:
java.lang.ClassNotFoundException com.jadex.qna.QNAProject.App
因此,清楚错误的根源是什么。您正在尝试执行其文件Maven无法找到的类的main()
方法。正如this SO article所讨论的那样,您可以先尝试显式编译,然后在生成类文件后执行:
mvn -e compile exec:java
mvn exec:java -Dexec.mainClass="com.jadex.qna.QNAProject.App"
答案 2 :(得分:0)
我遇到了同样的问题,这是由端口冲突引起的。 我的tomcat服务器尝试在端口8080上启动,但我已经有了它的绑定。 netstat -anto将显示端口绑定0.0.0.0:8080或类似的,它的PID将帮助您确定哪个进程已经在运行端口出价,要么在您的timcat服务器中更改它,要么在任何进程中使用出价。可能是由IIS,SKype或类似的引起的。