未能执行目标 org.codehaus.mojo:exec-maven-plugin:1.2:java (default-cli)

Posted

技术标签:

【中文标题】未能执行目标 org.codehaus.mojo:exec-maven-plugin:1.2:java (default-cli)【英文标题】:Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2:java (default-cli) 【发布时间】:2013-08-03 09:43:47 【问题描述】:

我正在研究 Smooks - Camel 集成。我遇到了一个错误。构建失败 当我尝试使用 mvn exec:java

运行它时

[错误]: 未能在项目上执行目标 org.codehaus.mojo:exec-maven-plugin:1.2:java (default-cli) 骆驼示例-smooks-集成:

我的控制台日志如下:

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

C:\apache-camel-2.11.0\examples\camel-example-smooks-integration>mvn exec:java
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for
org.apache.camel:camel-example-smooks-integration:bundle:2.11.0
[WARNING] 'build.plugins.plugin.(groupId:artifactId)' must be unique but found duplicate   
declaration of plugin org.codehaus.mojo:exec-maven-plugin @ line 138, column 9

[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of 
 your build.

[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed 
projects.

[WARNING]

[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building CAMEL SMOOKS-INTEGRATION 2.11.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> exec-maven-plugin:1.2:java (default-cli) @ camel-example-smooks-integration >>>
[INFO]
[INFO] --- maven-bundle-plugin:2.3.7:cleanVersions (versions) @ camel-example-smooks-
 integration ---
[INFO]
[INFO] <<< exec-maven-plugin:1.2:java (default-cli) @ camel-example-smooks-integration <<<
[INFO]
[INFO] --- exec-maven-plugin:1.2:java (default-cli) @ camel-example-smooks-integration ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.229s
[INFO] Finished at: Thu Aug 01 20:29:09 IST 2013
[INFO] Final Memory: 9M/22M
[INFO] ------------------------------------------------------------------------

[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2:java (default-cli) on    
project camel-example-smooks-integration: An exception occured while executing the Java class. 
C:\apache-camel-2.11.0\examples\camel-example-smooks -integration\src\main\java\example\Main -> 
[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

我的 POM.xml 内容如下:

<?xml version="1.0" encoding="UTF-8"?>

<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/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.apache.camel</groupId>
        <artifactId>examples</artifactId>
        <version>2.11.0</version>
    </parent>

    <artifactId>camel-example-smooks-integration</artifactId>
    <packaging>bundle</packaging>
    <name>CAMEL SMOOKS-INTEGRATION</name>

    <description>An example for showing Camel Smooks Integration</description>


    <dependencies>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-spring</artifactId>
        </dependency>


        <dependency>
            <groupId>org.milyn</groupId>
            <artifactId>milyn-smooks-core</artifactId>
            <version>1.5.1</version>
        </dependency>



        <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
            <version>2.6</version>
        </dependency>

        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
            <version>1.1.3</version>
        </dependency>



        <dependency>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.5.1</version>
        </dependency>


        <!-- logging -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
        </dependency>

        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
        </dependency>

        <!-- for testing -->

        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-test</artifactId>
            <version>2.0-M3</version>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>

            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>attach-artifacts</id>
                        <phase>package</phase>
                        <goals>
                            <goal>attach-artifact</goal>
                        </goals>


                        <configuration>
                            <artifacts>
                                <artifact>
                                    <file>target/classes/features.xml</file> 
                                    <type>xml</type>
                                    <classifier>features</classifier>
                                </artifact>
                            </artifacts>
                        </configuration>
                    </execution>  
                </executions>
            </plugin>



            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                    <compilerArgument>-proc:none</compilerArgument>
                </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>
                    <mainClass>C:\apache-camel-2.11.0\examples\camel-example-smooks-  
                        integration\src\main\java\example\Main</mainClass>
                </configuration>
            </plugin>


            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>2.13</version>
                <configuration>
                    <skipTests>true</skipTests>
                </configuration>
            </plugin>


            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <version>2.3.7</version>
                <extensions>true</extensions>
                <configuration>
                    <instructions>
                        <Bundle-SymbolicName>osgi.org.springframework.batch</Bundle-SymbolicName>
                        <Export-Package>*</Export-Package>
                        <Import-Package>*</Import-Package>
                    </instructions>
                    <unpackBundle>true</unpackBundle>
                </configuration>
            </plugin>



            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.2</version>
            </plugin>
        </plugins>

    </build>
</project>

到目前为止,我已经尝试了以下操作来消除此错误,但尚未取得任何成功。

1.DownGraded the JDK from  Version 1.7 to jdk1.6.0_18

2.Added the **main class** in the **plugin for org.codehaus.mojo**

          <configuration>
            <mainClass>C:\apache-camel-2.11.0\examples\camel-example-smooks-integration\src\main\java\example\Main</mainClass>
        </configuration>

【问题讨论】:

寻找解决此问题的建议 尝试mvn -X exec:java 启用完整的调试日志记录,您应该有更多信息 我有同样的问题(使用较新的版本),但只是当我尝试从一个带有 PSVM 的新类运行项目时(测试一些方法)。如果我从原始的“主”类运行它,则不会出现此错误。 Main1.class(第一个也是唯一一个使用 PSVM 的类),在 Another.class 上调用方法,但如果我尝试直接运行 Another.class(使用 PSVM),则会引发错误 先生。 Pineda 在这里说得很好,这对我有帮助:***.com/questions/59765574/… 【参考方案1】:

我也遇到过类似的问题。

结果我跑了

mvn clean package install

正确的方法是

mvn clean install

【讨论】:

在 Netbeans 中哪里可以做到这一点? 我不使用 NetBeans。我在命令行中运行了命令。我记得,Eclipse 允许创建构建任务。 这些命令是等效的。 Maven 将在the lifecycle 中运行所有前面的步骤,因此指定install 意味着package 也将运行,compile 等也将运行。【参考方案2】:

你的问题是你已经声明了两次 exec-maven-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>
        <mainClass>C:\apache-camel-2.11.0\examples\camel-example-smooks-  
      integration\src\main\java\example\Main< /mainClass>
    </configuration>
</plugin>

...

< plugin>
    < groupId>org.codehaus.mojo</groupId>
    < artifactId>exec-maven-plugin</artifactId>
    < version>1.2</version>
< /plugin>

【讨论】:

嘿 Pith,我尝试删除 org.codehaus.mojo 的重复条目,但仍然失败并出现同样的错误: 你已经删除了整个插件,而不仅仅是 groupId ?【参考方案3】:

我有同样的问题,但删除旧插件后 org.codehaus.mojo 成功了。

我用这个

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>1.2</version>
</plugin>

【讨论】:

【参考方案4】:

'org.codehaus.mojo'-'jaxws-maven-plugin' 有类似的问题:无法解决依赖关系。幸运的是,我能够在 Eclipse 中执行 Project > Clean,从而解决了这个问题。

【讨论】:

【参考方案5】:

在 IntelliJ 中解决这个问题... 1) 将您的 .fxml 文件放入 resources 目录 2) 在 Start 方法中,按以下方式定义 .fxml 文件的路径:Parent root = FXMLLoader.load(getClass().getResource("/sample.fxml"));/ 似乎为我解决了这个问题:)

【讨论】:

以上是关于未能执行目标 org.codehaus.mojo:exec-maven-plugin:1.2:java (default-cli)的主要内容,如果未能解决你的问题,请参考以下文章

Maven 不会运行我的项目:无法执行目标 org.codehaus.mojo:exec-maven-plugin:1.2.1:exec

无法在项目 mavenproject2 上执行目标 org.codehaus.mojo:exec-maven-plugin:1.3.2:exec (默认):

Maven错误:无法执行目标org.codehaus.mojo:exec-maven-plugin:1.2.1:exec

目标 org.codehaus.mojo:exec-maven-plugin:1.6.0:java 的参数“mainClass”丢失或无效

Maven 和 Java:目标 org.codehaus.mojo:exec-maven-plugin:1.2.1:java 的参数“mainClass”丢失或无效

在 Maven 中从测试范围运行 main:“目标 org.codehaus.mojo:exec-maven-plugin:1.6.0:java 的参数 'mainClass' 丢失或无效”