简体   繁体   English

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

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

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) onproject 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.

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>

</project>

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?如果没有,有谁知道如何通过 Netbeans 使用 -e 或 -X 开关运行 Maven? I assume it is via a right click on the POM and then run goal then entering something in the textfield there.我假设是通过右键单击 POM,然后运行目标,然后在文本字段中输入内容。

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

I did the following :我做了以下事情:

  • I closed it on netbeans.我在netbeans上关闭了它。
  • Then open the project by clicking "Open Project", selecting my project and然后通过单击“打开项目”打开项目,选择我的项目和
  • Simply hit the run button in 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.通过单击“浏览”并选择正确设置“主类”。

I faced the same issue.我遇到了同样的问题。 When I tried to run the project from IDE, it was giving me same error.当我尝试从 IDE 运行该项目时,它给了我同样的错误。 But when I tried running from the command prompt, the project was running fine.但是当我尝试从命令提示符运行时,该项目运行良好。 So it came to me that there should be some issue with the settings that makes the program to Run from IDE.因此,我认为使程序从 IDE 运行的设置应该存在一些问题。

I solved the problem by changing some Project settings.我通过更改一些项目设置解决了这个问题。 I traced the error and came to the following part in my pom.xml file.我跟踪了错误并在我的 pom.xml 文件中找到了以下部分。

            <execution>
                <id>default-cli</id>
                <goals>
                    <goal>exec</goal>                            
                </goals>
                <configuration>
                    <executable>${java.home}/bin/java</executable>
                    <commandlineArgs>${runfx.args}</commandlineArgs>
                </configuration>
            </execution>

I went to my Project Properties > Actions Categories > Action: Run Project: then I Set Properties for Run Project Action as follows:我转到我的项目属性>操作类别>操作:运行项目:然后我为运行项目操作设置属性,如下所示:

runfx.args=-jar "${project.build.directory}/${project.build.finalName}.jar"

Then, I rebuild the project and I was able to Run the Project.然后,我重建了该项目,并且能够运行该项目。 As you can see, the IDE(Netbeans in my case), was not able to find 'runfx.args' which is set in Project Properties.如您所见,IDE(在我的情况下为 Netbeans)无法找到在项目属性中设置的“runfx.args”。

I am a beginner in Maven - don't know much about it.我是 Maven 的初学者 - 不太了解它。 Carefully check on your input ie 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.在我修复它之后,它神奇地起作用了哈哈。

A solution which worked in my case is:在我的情况下有效的解决方案是:
1. Go to the module having Main class. 1. 转到具有 Main 类的模块。
2. Right click on pom.xml under this module. 2. 右键单击​​该模块下的 pom.xml。
3. Select "Run Maven" -> "UpdateSnapshots" 3.选择“运行Maven”->“UpdateSnapshots”

  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.如果您使用的是 netbeans 7.4,请尝试禁用“保存时编译”。

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

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

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.删除了 Netbeans 7.4 并从 oracle 的站点重新安装它。
  2. Installed plugins for maven, ant and java that may be related to the project.已安装可能与项目相关的 maven、ant 和 java 插件。
  3. Deleted .nbproject folder - after that the project was considered a maven project.删除 .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.此外,在那之后,我发现该项目运行,但退出代码为 1,因为我没有为其提供命令行参数。 And the builder considers it is an error.建造者认为这是一个错误。 So, look carefully for the output and see if the program actually starts.所以,仔细查看输出,看看程序是否真的启动了。

Maven needs to be able to access various Maven repositories in order to download artifacts to the local repository. Maven 需要能够访问各种 Maven 存储库,以便将工件下载到本地存储库。 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.xml file.如果您的本地系统通过代理主机访问 Internet,您可能需要通过编辑 Maven settings.xml文件为 Maven 显式指定代理设置。 Maven builds ignore the IDE proxy settings that are set in the Options window. Maven 构建会忽略在“选项”窗口中设置的 IDE 代理设置。 For many common cases, just passing -Djava.net.useSystemProxies=true to Maven should suffice to download artifacts through the system's configured proxy.对于许多常见情况,只需将-Djava.net.useSystemProxies=true传递给 Maven 就足以通过系统配置的代理下载工件。 NetBeans 7.1 will offer to configure this flag for you if it detects a possible proxy problem.如果 NetBeans 7.1 检测到可能的代理问题,它将为您配置此标志。 https://netbeans.org/bugzilla/show_bug.cgi?id=194916 has discussion. https://netbeans.org/bugzilla/show_bug.cgi?id=194916有讨论。

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

Netbeans needs to be able to index the maven repository. Netbeans 需要能够索引 maven 存储库。 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它给了我同样的错误,在它索引存储库后,它像魅力一样运行

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

重新启动 Netbeans 并解决了我的问题。

Im new to java hibernate but i could solve this problem, this is how i did it : I was working with hibernate and maven project.我是 java hibernate 的新手,但我可以解决这个问题,我是这样做的:我正在使用 hibernate 和 maven 项目。 First you have to put persistence.xml under project directory, then add jdbc manually.首先你必须将persistence.xml放在项目目录下,然后手动添加jdbc。 Maven couldn't download my dependency so i added it manually. Maven 无法下载我的依赖项,所以我手动添加了它。 In the persistence.xml in design jdbc connection add it manually ps: i work with netbeans good luck在设计 jdbc 连接的persistence.xml 中手动添加 ps:我与 netbeans 一起工作祝你好运

For me, the clue was the "org.codehaus.mojo:exec-maven-plugin:1.2.1:exec".对我来说,线索是“org.codehaus.mojo:exec-maven-plugin:1.2.1:exec”。
The only place this was referenced was in the "Run project" action under Project Properties=>Actions.唯一被引用的地方是在 Project Properties=>Actions 下的“Run project”操作中。

When I changed this action to match the HelloFXMLWithMaven sample project (available in Netbeans 11.1): "clean javafx:run" then executing the Run goal was able to proceed.当我更改此操作以匹配 HelloFXMLWithMaven 示例项目(在 Netbeans 11.1 中可用)时:“clean javafx:ru​​n”然后执行 Run 目标能够继续。

Note, I also had to update the pom file's javafx-maven-plugin to also match the sample project but with the mainClass changed for my project.请注意,我还必须更新 pom 文件的 javafx-maven-plugin 以匹配示例项目,但我的项目的 mainClass 已更改。

Rohith HY Solved this problem Rohith HY 解决了这个问题

  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.通过单击“浏览”并选择正确设置“主类”。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 netbeans运行错误:无法执行目标org.codehaus.mojo:exec-maven-plugin:1.2.1 - netbeans Run error :Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1 Maven错误:无法执行目标org.codehaus.mojo:exec-maven-plugin:1.2.1:exec - Maven error: Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec Smooks-无法执行目标org.codehaus.mojo:exec-maven-plugin:1.2.1:exec - Smooks - Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec 无法执行目标org.codehaus.mojo:exec-maven-plugin:1.2.1:exec( - Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec ( 无法执行目标org.codehaus.mojo:exec-maven-plugin:1.2.1:exec - Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec 我尝试运行我的Maven项目时遇到错误:无法执行目标org.codehaus.mojo:exec-maven-plugin:1.2.1:exec(default-cli) - I have an error when i trying to run my maven project: Failed execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (default-cli) 无法在项目上执行目标org.codehaus.mojo:exec-maven-plugin:1.2.1:exec(default-cli):命令执行失败 - Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (default-cli) on project: Command execution failed 无法在项目SpringData上执行目标org.codehaus.mojo:exec-maven-plugin:1.2.1:exec(default-cli) - Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (default-cli) on project SpringData 无法执行目标org.codehaus.mojo:exec-maven-plugin:1.2.1 - kafka风暴集成 - Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1 - kafka storm integration Eclipse:无法执行目标org.codehaus.mojo:exec-maven-plugin:1.2.1:exec(默认值):命令执行失败 - Eclipse: Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (default): Command execution failed
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM