Java Maven MojoExecutionException
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23235430/
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
Maven MojoExecutionException
提问by astack
I am facing this issue , when i am deploying my application using Maven, please suggest some solution.
我正面临这个问题,当我使用 Maven 部署我的应用程序时,请提出一些解决方案。
Error log,
错误日志,
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 19.790s
[INFO] Finished at: Wed Apr 23 10:44:13 IST 2014
[INFO] Final Memory: 54M/131M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project clustering.services: Fatal error compiling: tools.jar not found: C:\Program Files\Java\jre7\..\lib\tools.jar -> [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
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :clustering.services
Thanks in advance.
提前致谢。
采纳答案by Jigar Joshi
回答by Alex
If you're using Eclipse, go to Windows->Preferences. Under Java->Installed JREs, double click on the item in the list and make sure the JRE home points to a JDK (for example, set it to "C:\Program Files\Java\jdk1.7.0_60"), and leave everything else the same.
如果您使用的是 Eclipse,请转至 Windows->Preferences。在 Java->Installed JREs 下,双击列表中的项目并确保 JRE home 指向 JDK(例如,将其设置为“C:\Program Files\Java\jdk1.7.0_60”),然后离开其他一切都一样。
回答by Jairo Ernesto Sánchez Galvis
Verify that the name of the main class to execute in the application is specified in the pom.xml.
验证要在应用程序中执行的主类的名称是否在 pom.xml 中指定。
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<mainClass>com.enterprise.mainPacket.MainApp</mainClass>
</properties>
Also check if the .fxml file has been relocated, so that it correctly addresses the controller associated with it. fx:controller="com.enterprise.mainPacket.FXMLController"
还要检查 .fxml 文件是否已重新定位,以便它正确寻址与其关联的控制器。fx:controller="com.enterprise.mainPacket.FXMLController"
<VBox fx:id="vBMasterContainer" prefHeight="698.0" prefWidth="800.0" styleClass="theme" stylesheets="@/styles/style.css" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.enterprise.mainPacket.FXMLController">
回答by chamzz.dot
make sure that you don't have empty pakages within your sourcecode folder.If there are no any classes Same error will occur
确保您的源代码文件夹中没有空包。如果没有任何类,则会发生相同的错误
回答by Aguid
Check that there are no conflict on the port (another service already running) !
检查端口上没有冲突(另一个服务已经在运行)!
回答by Alex Stoliar
I had the same error. i fixed the path to java, and was missing the tools jar. i copied it from another place. after that everything worked.
我有同样的错误。我修复了java的路径,但缺少工具jar。我从另一个地方复制的。之后一切正常。
回答by user11252935
I changed the version in pom.xml to 1.2.1 and the error was resolved.
我将 pom.xml 中的版本更改为 1.2.1 并解决了错误。
回答by QA Specialist
Most of the time that i get this "Mojo" error. It is just because, i may have forgotten to do "Maven generate-sources"then "Maven Clean"prior to do the "Maven Install" or "Maven Build". The MojoExecutionException should not appear after that. Some Eclipse versions have this problem to refresh the target folder. In this case, Refresh the project just after the "Maven Install".
大多数情况下,我都会收到此“Mojo”错误。正是由于,我可能已经忘记了做“Maven的产生来源”,然后“Maven的清洁”做事先“Maven的安装”或“Maven构建”。之后不应出现 MojoExecutionException。某些 Eclipse 版本存在刷新目标文件夹的问题。在这种情况下,在“Maven Install”之后刷新项目。
Also, the MojoExecutionException may occur if you have a (not compatible) jar version in your libraries as the following example screenshot. Remove it or replace it with the same (compiled) version (java 1.8 <64 bit> in my case) then do the "Maven generate-sources" and "Maven Clean" **prior to do the "Maven Install":
此外,如果您的库中有(不兼容的)jar 版本,则可能会发生 MojoExecutionException,如以下示例屏幕截图所示。删除它或用相同的(编译的)版本(在我的情况下为 java 1.8 <64 位>)替换它,然后在执行“Maven 安装”之前执行“Maven generate-sources”和“Maven Clean”**:
If a new java version happened to be installed on your PC, you just need to go from Project-> Properties-->Java Build Path then select the Workspace default JRE (jdk 1.8) and click on the Finish button ... Click on Maven Install, the MojoFailureException should no longer occurs.
如果您的 PC 上碰巧安装了新的 Java 版本,您只需要从 Project-> Properties-->Java Build Path 然后选择 Workspace 默认 JRE (jdk 1.8) 并单击 Finish 按钮...单击Maven 安装,MojoFailureException 不应再发生。