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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20077870/
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-08-12 22:56:06  来源:igfitidea点击:

Maven won't run my Project : Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec

javamavennetbeansmaven-2javafx

提问by Oliver Watkins

I can't run the Maven Netbeans JavaFX example :

我无法运行 Maven Netbeans JavaFX 示例:

Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (default-cli) on project mavenproject3: Command execution failed. Process exited with an error: 1 (Exit value: 1) -> [Help 1]

To see the full stack trace of the errors, re-run Maven with the -e switch. Re-run Maven using the -X switch to enable full debug logging.

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

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

My POM looks like this :

我的 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>

Does anyone know why this is happening?

有谁知道为什么会这样?

And if not, does anyone know how to get Maven running with the -e or the -X switch via Netbeans? I assume it is via a right click on the POM and then run goal then entering something in the textfield there.

如果没有,有谁知道如何通过 Netbeans 使用 -e 或 -X 开关运行 Maven?我假设它是通过在 POM 上单击鼠标右键,然后运行目标,然后在那里的文本字段中输入一些内容。

回答by mkleint

  1. what's happening? you haven' shown much of the output to be able to decide. if you are using netbeans 7.4, try disabling Compile on Save.

  2. to enable debug output, either run Custom > Goals... action from project popup or after running a regular build, click the Rerun with options action from the output's toolbar

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

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

回答by Aaron Digulla

Try to run Maven from the command line or type "-X" in the text field - you can't break anything this way, at the worst, you'll get an error (I don't have Netbeans; in Eclipse, there is a checkbox "Debug" for this).

尝试从命令行运行 Maven 或在文本字段中输入“-X” - 你不能以这种方式破坏任何东西,最糟糕的是,你会得到一个错误(我没有 Netbeans;在 Eclipse 中,有是一个复选框“调试”)。

When running with debug output enabled, you should see the paths which the exec-maven-plugin plugin uses.

在启用调试输出的情况下运行时,您应该看到 exec-maven-plugin 插件使用的路径。

The next step would then be to copy the command into a command prompt or terminal and execute it manually to see if you get a useful error message there.

下一步是将命令复制到命令提示符或终端中并手动执行它以查看是否在那里收到有用的错误消息。

回答by Kenny O. Cruz

Had the same problem, I worked around it by changing ${java.home}/../bin/javafxpackager to ${java.home}/bin/javafxpackager

遇到了同样的问题,我通过将 ${java.home}/../bin/javafxpackager 更改为 ${java.home}/bin/javafxpackager 来解决它

回答by Ilya Sheershoff

Had the same problem after installing oracle jdk on Ubuntu 13.10 x64.

在 Ubuntu 13.10 x64 上安装 oracle jdk 后遇到同样的问题。

I've done the following steps, not sure which one helped. I think that at least 2 and 3 are necessary.

我已经完成了以下步骤,不确定哪一个有帮助。我认为至少2和3是必要的。

  1. Deleted Netbeans 7.4 and reinstalled it from oracle's site.
  2. Installed plugins for maven, ant and java that may be related to the project.
  3. Deleted .nbproject folder - after that the project was considered a maven project.
  1. 删除了 Netbeans 7.4 并从 oracle 的站点重新安装它。
  2. 已安装可能与项目相关的 maven、ant 和 java 插件。
  3. 删除 .nbproject 文件夹 - 之后该项目被视为 maven 项目。

Also, after that, I've found that the project runs, but exits with exit code 1 because I didn't supply the command line parameters for it. And the builder considers it is an error. So, look carefully for the output and see if the program actually starts.

此外,在那之后,我发现该项目运行,但退出代码为 1,因为我没有为其提供命令行参数。建造者认为这是一个错误。所以,仔细查看输出,看看程序是否真的启动了。

回答by theteddyboy

I am a beginner in Maven - don't know much about it. Carefully check on your input i.e. file path in my case. After I have carefully check, my file path is wrong so it leads to this error. After I fixed it, it works magically lol.

我是 Maven 的初学者 - 不太了解它。在我的情况下,仔细检查您的输入,即文件路径。仔细检查后,我的文件路径错误,因此导致此错误。在我修复它之后,它神奇地起作用了哈哈。

回答by Naveen Sharma

A solution which worked in my case is:
  1. Go to the module having Main class.
  2. Right click on pom.xml under this module.
  3. Select "Run Maven" -> "UpdateSnapshots"

在我的情况下有效的解决方案是:
  1. 转到具有 Main 类的模块。
  2. 右键单击​​该模块下的 pom.xml。
  3.选择“运行Maven”->“UpdateSnapshots”

回答by Pooria Alimardani

Maven needs to be able to access various Maven repositories in order to download artifacts to the local repository. If your local system is accessing the Internet through a proxy host, you might need to explicitly specify the proxy settings for Maven by editing the Maven settings.xmlfile. Maven builds ignore the IDE proxy settings that are set in the Options window.For many common cases, just passing -Djava.net.useSystemProxies=trueto Maven should suffice to download artifacts through the system's configured proxy. NetBeans 7.1 will offer to configure this flag for you if it detects a possible proxy problem. https://netbeans.org/bugzilla/show_bug.cgi?id=194916has discussion.

Maven 需要能够访问各种 Maven 存储库,以便将工件下载到本地存储库。如果您的本地系统通过代理主机访问 Internet,您可能需要通过编辑 Mavensettings.xml文件来明确指定 Maven 的代理设置。Maven 构建会忽略在“选项”窗口中设置的 IDE 代理设置。对于许多常见情况,只需传递-Djava.net.useSystemProxies=true给 Maven 就足以通过系统配置的代理下载工件。如果 NetBeans 7.1 检测到可能的代理问题,它将为您配置此标志。https://netbeans.org/bugzilla/show_bug.cgi?id=194916有讨论。

回答by Rohith H.Y

  1. This error would spring up arbitrarily and caused quite a bit of trouble though the code on my end was solid.
  1. 这个错误会随意出现并引起相当多的麻烦,尽管我的代码是可靠的。

I did the following :

我做了以下事情:

  • I closed it on netbeans.
  • Then open the project by clicking "Open Project", selecting my project and
  • Simply hit the run button in netbeans.
  • 我在netbeans上关闭了它。
  • 然后通过单击“打开项目”打开项目,选择我的项目和
  • 只需点击 netbeans 中的运行按钮。

I would not build or clean build it. Hope that helps you out.

我不会构建或清理构建它。希望能帮到你。

  1. I noticed another reason why this happens. If you moved your main class to another package, the same error springs up. In that case you :
    • Right Click Project > Properties > Run
    • Set the "Main Class" correctly by clicking "Browse" and selecting.
  1. 我注意到发生这种情况的另一个原因。如果您将主类移动到另一个包,则会出现相同的错误。在这种情况下,您:
    • 右键单击项目 > 属性 > 运行
    • 通过单击“浏览”并选择正确设置“主类”。

回答by devrocca

I solved this issue with right click on project -> Set as Main Project.

我通过右键单击项目-> 设置为主项目解决了这个问题。

回答by agcala

Netbeans needs to be able to index the maven repository.Allow it to do that and try again. It was giving me the same error and after it indexed the repository it ran like a charm

Netbeans 需要能够索引 maven 存储库。让它这样做,然后再试一次。它给了我同样的错误,在它索引存储库后,它像魅力一样运行