eclipse exec-maven-plugin 错误,即使在工作示例中

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30836673/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 22:42:09  来源:igfitidea点击:

exec-maven-plugin error, even on working example

javaeclipsemaven

提问by Prunus Nira

EDIT5 Updated /

EDIT5 更新 /

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

我正在使用 Maven 3.3.3。
我只是创建了新项目并添加了 compile 和 exec 插件,作为网络上的示例。
我试图执行,但出现错误

[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>

I tried exec-maven-plugin version 1.2.1 and 1.4.0, but got same error. Here is my pom.xml

我尝试了 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>

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-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-项目与 Maven/

but I got same error.

但我遇到了同样的错误。

I unzipped maven at C:\apache-maven-3.3.3 and created environment variable MAVEN_HOME as same path. What is the problem?

我在 C:\apache-maven-3.3.3 解压了 maven 并创建了环境变量 MAVEN_HOME 作为相同的路径。问题是什么?

====================================

====================================

EDIT: Here is the result

编辑:这是结果

enter image description here

enter image description here

Well.. I set MAVEN_HOME, not M2_HOME because tutorial what I found said to set it only...
Of course, echo %MAVEN_HOME% shows

好吧..我设置了 MAVEN_HOME,而不是 M2_HOME,因为我发现的教程只说设置它......
当然,echo %MAVEN_HOME% 显示

C:\apache-maven-3.3.3

C:\apache-maven-3.3.3

is it wrong?

这是错的吗?

I added %MAVEN_HOME%\bin to PATH variable, but it did not work too.
And, I'm using eclipse

我将 %MAVEN_HOME%\bin 添加到 PATH 变量,但它也不起作用。
而且,我正在使用日食

=====================================

======================================

EDIT2: Here is full log. I used goal 'clean exec:java -e -X'

EDIT2:这是完整的日志。我使用了目标 'clean exec:java -e -X'

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

太长了,所以我上传到我的博客这里。
请注意,我将存储库文件夹从 C:\Users.....m2 更改为新的本地存储库文件夹 C:\apache-maven-localrepository

https://arincblossom.wordpress.com/2015/06/15/error-logs/

https://arincblossom.wordpress.com/2015/06/15/error-logs/

=======================================

========================================

EDIT3: I changed maven-compiler-plugin setting like this

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>

It prevented me from having error from mvn -e compile exec:javabut I can't run with mvn exec:java -Dexec.mainClass="com.jadex.qna.QNAProject.App"

它阻止了我的错误,mvn -e compile exec:java但我无法运行mvn exec:java -Dexec.mainClass="com.jadex.qna.QNAProject.App"

=================================

==================================

EDIT4: OK, I'll try from the bottom, and post again. Thanks for your sincere helps.

EDIT4:好的,我会从底部开始尝试,然后再次发布。感谢您的真诚帮助。

======================================

======================================

EDIT5

编辑5

I reset all the sequences... re-installed eclipse, maven.. and re-created projects... but nothing worked...

我重置了所有序列......重新安装了eclipse,maven......并重新创建了项目......但没有任何效果......

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.

我更改了 eclipse 设置以将 JDK 路径修复为已安装的 jdk 路径,而不是 JRE 路径。然后我发现 'mvn -e clean compile exec:java' 正在工作,但我只想 'mvn clean exec:java' 工作。它根本不起作用。

You can check full source here

您可以在此处查看完整来源

https://github.com/arincblossom/MavenTestProject

https://github.com/arincblossom/MavenTestProject

This is current console message for 'mvn -e 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.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

采纳答案by Tim Biegeleisen

The error log which you posted says the following:

您发布的错误日志如下:

java.lang.ClassNotFoundException  com.jadex.qna.QNAProject.App

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 articlediscusses, you can try explicitly compiling first, then executing after the class file has been generated:

所以很清楚错误的根源是什么。您正在尝试执行main()Maven 找不到其类文件的类的方法。正如这篇 SO 文章所讨论的,您可以先尝试显式编译,然后在生成类文件后执行:

mvn -e compile exec:java
mvn exec:java -Dexec.mainClass="com.jadex.qna.QNAProject.App"

回答by Sireesh Yarlagadda

This issue happens, when it is not compatible with eclipse too.

当它也与 eclipse 不兼容时,就会发生此问题。

Try this

尝试这个

mvn clean install eclipse:eclipse

Vote up, if it works to help fellow members

投票,如果它可以帮助其他成员

回答by Mattias

I ran into this same problem, it was caused by a port conflict. my tomcat server tried to start on port 8080 but i already had a binding for it. netstat -anto will show you port bindings 0.0.0.0:8080 or similar and it's PID this will help you determin what process is already running the port bidning, either change it in your timcat server or whatever process is using the bidning. Could be caused by an IIS, SKype or similar.

我遇到了同样的问题,它是由端口冲突引起的。我的 tomcat 服务器试图在端口 8080 上启动,但我已经绑定了它。netstat -anto 将向您显示端口绑定 0.0.0.0:8080 或类似的 PID,这将帮助您确定哪个进程已经在运行端口竞价,在您的 timcat 服务器中更改它或使用竞价的任何进程。可能是由 IIS、SKYPE 或类似程序引起的。