简体   繁体   English

无法在项目上执行目标 org.apache.maven.plugins:maven-compiler-plugin (default-compile): Fatal error compiling: tools.jar not found

[英]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.有用。

Check the JAVA version, It should be same across all the places.检查JAVA版本,它应该在所有地方都一样。 See screenshots.见截图。

  1. pom.xml pom.xml 在此处输入图片说明
  2. JAVA build path JAVA构建路径在此处输入图片说明
  3. JAVA compiler JAVA编译器在此处输入图片说明

Note: To see configuration window for 2 and 3... right click on the project and click properties注意:要查看 2 和 3 的配置窗口...右键单击项目并单击属性

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.

相关问题 无法在项目 fhirql 上执行目标 org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile):致命错误编译 - Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project fhirql: Fatal error compiling tools.jar问题无法执行目标org.apache.maven.plugins:maven-compiler-plugin - tools.jar issue Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin 无法执行目标org.apache.maven.plugins:maven-compiler-plugin:3.5.1:在项目上编译(default-compile) - Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.5.1:compile (default-compile) on project 无法在项目上执行目标org.apache.maven.plugins:maven-compiler-plugin:3.3:compile(default-compile) - Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.3:compile (default-compile) on project 无法在项目 dbproxy 上执行目标 org.apache.maven.plugins:maven-compiler-plugin:3.0:compile (default-compile): - Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.0:compile (default-compile) on project dbproxy: 无法执行目标 org.apache.maven.plugins:maven-compiler-plugin:2。 3.2:在项目aopencommon上编译(默认编译) - Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2. 3.2:compile (default-compile) on project aopencommon 无法在项目上执行目标org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile(default-compile) - Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project Maven 构建编译错误:无法在项目 Maven 上执行目标 org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) - Maven build Compilation error : Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project Maven 无法执行目标 org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) - Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) 未能执行目标 org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) - Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM