![](/img/trans.png)
[英]netbeans Run error :Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1
[英]Maven won't run my Project : Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec
我無法運行 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.
我的 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>
有誰知道為什么會這樣?
如果沒有,有誰知道如何通過 Netbeans 使用 -e 或 -X 開關運行 Maven? 我假設是通過右鍵單擊 POM,然后運行目標,然后在文本字段中輸入內容。
我做了以下事情:
我不會構建或清理構建它。 希望能幫到你。
我遇到了同樣的問題。 當我嘗試從 IDE 運行該項目時,它給了我同樣的錯誤。 但是當我嘗試從命令提示符運行時,該項目運行良好。 因此,我認為使程序從 IDE 運行的設置應該存在一些問題。
我通過更改一些項目設置解決了這個問題。 我跟蹤了錯誤並在我的 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>
我轉到我的項目屬性>操作類別>操作:運行項目:然后我為運行項目操作設置屬性,如下所示:
runfx.args=-jar "${project.build.directory}/${project.build.finalName}.jar"
然后,我重建了該項目,並且能夠運行該項目。 如您所見,IDE(在我的情況下為 Netbeans)無法找到在項目屬性中設置的“runfx.args”。
我是 Maven 的初學者 - 不太了解它。 在我的情況下,仔細檢查您的輸入,即文件路徑。 仔細檢查后,我的文件路徑錯誤,因此導致此錯誤。 在我修復它之后,它神奇地起作用了哈哈。
在我的情況下有效的解決方案是:
1. 轉到具有 Main 類的模塊。
2. 右鍵單擊該模塊下的 pom.xml。
3.選擇“運行Maven”->“UpdateSnapshots”
怎么了? 你還沒有展示出很多能夠決定的輸出。 如果您使用的是 netbeans 7.4,請嘗試禁用“保存時編譯”。
要啟用調試輸出,請從項目彈出窗口運行自定義 > 目標...操作,或者在運行常規構建后,單擊輸出工具欄中的 Rerun with options 操作
遇到了同樣的問題,我通過將 ${java.home}/../bin/javafxpackager 更改為 ${java.home}/bin/javafxpackager 來解決它
在 Ubuntu 13.10 x64 上安裝 oracle jdk 后遇到同樣的問題。
我已經完成了以下步驟,不確定哪一個有幫助。 我認為至少2和3是必要的。
此外,在那之后,我發現該項目運行,但退出代碼為 1,因為我沒有為其提供命令行參數。 建造者認為這是一個錯誤。 所以,仔細查看輸出,看看程序是否真的啟動了。
Maven 需要能夠訪問各種 Maven 存儲庫,以便將工件下載到本地存儲庫。 如果您的本地系統通過代理主機訪問 Internet,您可能需要通過編輯 Maven settings.xml
文件為 Maven 顯式指定代理設置。 Maven 構建會忽略在“選項”窗口中設置的 IDE 代理設置。 對於許多常見情況,只需將-Djava.net.useSystemProxies=true
傳遞給 Maven 就足以通過系統配置的代理下載工件。 如果 NetBeans 7.1 檢測到可能的代理問題,它將為您配置此標志。 https://netbeans.org/bugzilla/show_bug.cgi?id=194916有討論。
我通過右鍵單擊項目-> 設置為主項目解決了這個問題。
Netbeans 需要能夠索引 maven 存儲庫。 讓它這樣做,然后再試一次。 它給了我同樣的錯誤,在它索引存儲庫后,它像魅力一樣運行
嘗試從命令行運行 Maven 或在文本字段中輸入“-X” - 你不能以這種方式破壞任何東西,最糟糕的是,你會得到一個錯誤(我沒有 Netbeans;在 Eclipse 中,有是一個復選框“調試”)。
在啟用調試輸出的情況下運行時,您應該看到 exec-maven-plugin 插件使用的路徑。
下一步是將命令復制到命令提示符或終端中並手動執行它以查看是否在那里收到有用的錯誤消息。
重新啟動 Netbeans 並解決了我的問題。
我是 java hibernate 的新手,但我可以解決這個問題,我是這樣做的:我正在使用 hibernate 和 maven 項目。 首先你必須將persistence.xml放在項目目錄下,然后手動添加jdbc。 Maven 無法下載我的依賴項,所以我手動添加了它。 在設計 jdbc 連接的persistence.xml 中手動添加 ps:我與 netbeans 一起工作祝你好運
對我來說,線索是“org.codehaus.mojo:exec-maven-plugin:1.2.1:exec”。
唯一被引用的地方是在 Project Properties=>Actions 下的“Run project”操作中。
當我更改此操作以匹配 HelloFXMLWithMaven 示例項目(在 Netbeans 11.1 中可用)時:“clean javafx:run”然后執行 Run 目標能夠繼續。
請注意,我還必須更新 pom 文件的 javafx-maven-plugin 以匹配示例項目,但我的項目的 mainClass 已更改。
Rohith HY 解決了這個問題
在那種情況下你:
右鍵單擊項目 > 屬性 > 運行
通過單擊“瀏覽”並選擇正確設置“主類”。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.