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

Oli*_*ins 15 java maven-2 netbeans javafx maven

我无法运行Maven Netbeans JavaFX示例:

无法在项目mavenproject3上执行目标org.codehaus.mojo:exec-maven-plugin:1.2.1:exec(default-cli):命令执行失败.进程退出并显示错误:1(退出值:1) - > [帮助1]

要查看错误的完整堆栈跟踪,请使用-e开关重新运行Maven.使用-X开关重新运行Maven以启用完整的调试日志记录.

我的POM看起来像这样:

<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.huw.almexoffice.client</groupId>
<artifactId>almex-office-client</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Almex Office Client</name>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <mainClass>com.huw.almexoffice.client.MainApp</mainClass>
</properties>

<organization>
    <!-- Used as the 'Vendor' for JNLP generation -->
    <name>Your Organisation</name>
</organization>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.6</version>
            <executions>
                <execution>
                    <id>unpack-dependencies</id>
                    <phase>package</phase>
                    <goals>
                        <goal>unpack-dependencies</goal>
                    </goals>
                    <configuration>
                        <excludeScope>system</excludeScope>
                        <excludeGroupIds>junit,org.mockito,org.hamcrest</excludeGroupIds>
                        <outputDirectory>${project.build.directory}/classes</outputDirectory>
                    </configuration>
                </execution>
            </executions>
        </plugin>            
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>1.2.1</version>
            <executions>
                <execution>
                    <id>unpack-dependencies</id>

                    <phase>package</phase>
                    <goals>
                        <goal>exec</goal>
                    </goals>
                    <configuration>
                        <executable>${java.home}/../bin/javafxpackager</executable>
                        <arguments>
                            <argument>-createjar</argument>
                            <argument>-nocss2bin</argument>
                            <argument>-appclass</argument>
                            <argument>${mainClass}</argument>
                            <argument>-srcdir</argument>
                            <argument>${project.build.directory}/classes</argument>
                            <argument>-outdir</argument>
                            <argument>${project.build.directory}</argument>
                            <argument>-outfile</argument>
                            <argument>${project.build.finalName}.jar</argument>
                        </arguments>
                    </configuration>
                </execution>
            </executions>  
        </plugin>



        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
                <compilerArguments>
                    <bootclasspath>${sun.boot.class.path}${path.separator}${java.home}/lib/jfxrt.jar</bootclasspath>
                </compilerArguments>
            </configuration>
        </plugin>
    </plugins>
</build>
Run Code Online (Sandbox Code Playgroud)

有谁知道为什么会这样?

如果没有,有没有人知道如何通过Netbeans使用-e或-X开关运行Maven?我假设是通过右键单击POM然后运行目标然后在文本字段中输入内容.

Roh*_*H.Y 5

  1. 尽管我端的代码很可靠,但该错误会任意出现,并引起很多麻烦。

我做了以下事情:

  • 我在netbeans上关闭了它。
  • 然后点击“打开项目”,选择我的项目并打开项目
  • 只需点击netbeans中的运行按钮。

我不会构建或清理它。希望对您有所帮助。

  1. 我注意到发生这种情况的另一个原因。如果您将主类移至另一个包,则会出现相同的错误。在这种情况下,您:
    • 右键单击项目>属性>运行
    • 通过单击“浏览”并选择正确设置“主类”。


mkl*_*int 2

  1. 发生了什么?您还没有显示出足够的输出来做出决定。如果您使用的是 netbeans 7.4,请尝试禁用“保存时编译”。

  2. 要启用调试输出,请从项目弹出窗口运行“自定义”>“目标...”操作,或者在运行常规构建后,单击输出工具栏中的“使用选项重新运行”操作