[英]Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin (default-compile) on project: Fatal error compiling: tools.jar not found
I have done all the steps provided in http://www.tutorialspoint.com/jsf/jsf_environment_setup.htm我已经完成了http://www.tutorialspoint.com/jsf/jsf_environment_setup.htm 中提供的所有步骤
Apache Maven and Apache tomcat both are ready. Apache Maven 和 Apache tomcat 都已准备就绪。 I also set the environments.
我还设置了环境。 I created Maven project in Eclipse, it gives Build Failure while I run this using Maven build.
我在 Eclipse 中创建了 Maven 项目,当我使用 Maven 构建运行它时它给出了构建失败。
It gives this error它给出了这个错误
"Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project Hello2: Fatal error compiling: tools.jar not found: C:\\Program Files\\Java\\jre1.8.0_40..\\lib\\tools.jar"
“无法执行目标 org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project Hello2: Fatal error compiler not found: tools.jar not found: C:\\Program Files\\Java \\jre1.8.0_40..\\lib\\tools.jar"
What should I do?我该怎么办?
You need to set eclipse's default installed "jre" to a jdk.您需要将 eclipse 的默认安装“jre”设置为 jdk。 Eclipse Window Menu => Preferences => enter search string "jre" in left navigation pane => click on "Installed JREs" in left navigation pane => Click Add and browse to your JDK.
Eclipse 窗口菜单 => 首选项 => 在左侧导航窗格中输入搜索字符串“jre” => 在左侧导航窗格中单击“已安装的 JRE” => 单击添加并浏览到您的 JDK。 => click the check box next to the JDK to make it default.
=> 单击 JDK 旁边的复选框以将其设为默认值。
You may need to download and install the java jdk if you don't already have it.如果您还没有 java jdk,则可能需要下载并安装它。
Also ensure the eclipse run configuration is set to use the default jdk you set up: Run Menu => Run Configurations => Select the run config for your project (Maven Build) => Click JRE tab => Under Runtime JRE select "workspace default".还要确保将 eclipse 运行配置设置为使用您设置的默认 jdk:运行菜单 => 运行配置 => 为您的项目选择运行配置(Maven 构建)=> 单击 JRE 选项卡 => 在 Runtime JRE 下选择“workspace default ”。
I delete my .m2 local local repository and re-run it.我删除了我的 .m2 本地本地存储库并重新运行它。 It works.
有用。
Delete repository from .m2 -> repository
and then right click on the project Run as... -> Maven install
.从
.m2 -> repository
删除存储库.m2 -> repository
,然后右键单击项目Run as... -> Maven install
。
After that, again right click on the project Maven -> Update project -> Check Update of Snapshots
and click on the Ok
option.之后,再次右键单击项目
Maven -> Update project -> Check Update of Snapshots
并单击Ok
选项。
I am using windows OS with JDK 1.9 in eclipse Oxygen.我在 eclipse Oxygen 中使用带有 JDK 1.9 的 Windows 操作系统。 I faced this issue while compiling the project with JDK 1.9 while using maven and I solved by changing
mvn.cmd
file present in C:\\apache-maven-3.5.2\\bin
.我在使用 maven 用 JDK 1.9 编译项目时遇到了这个问题,我通过更改
C:\\apache-maven-3.5.2\\bin
mvn.cmd
文件解决了这个问题。
Before:前:
set "JAVACMD=C:\Program Files\Java\jdk-9.0.1\bin\java.exe"
After:后:
set "JAVACMD=C:\Program Files\Java\jdk1.8.0_91\bin\java.exe"
Also, make sure the compiler you use to build the project is correctly configured in IDE you use.此外,请确保在您使用的 IDE 中正确配置了用于构建项目的编译器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.