简体   繁体   English

在Eclipse中导入Maven项目时发生了由于找不到tools.jar导致的错误

[英]Import Maven projects in Eclipse has error occurred that caused by couldn't find tools.jar

Error like the screen capture shows below occurred when I tried to import "Existing Maven Projects" with maven-checkstyle-plugin in Eclipse Oxygen. 当我尝试使用Eclipse Oxygen中的maven-checkstyle-plugin导入“现有Maven项目”时,发生了如下图所示的错误。 It looks like that Eclipse using default JRE path other than the JDK one which I had set in both environment variables and "JRE Installed" config in Eclipse. 看起来该Eclipse使用默认的JRE路径,而不是我在环境变量和Eclipse中的“ JRE Installed”配置中都设置的JDK路径。

当我在Eclipse Oxygen中使用maven-checkstyle-plugin导入现有Maven项目时发生错误

Full stack trace of exception found in "Error" View in Eclipse: 在Eclipse的“错误”视图中找到的异常的完整堆栈跟踪: 完整的异常跟踪堆栈

My Environment Variables setting: 我的环境变量设置:

JAVA_HOME设置

CLASSPATH设置

The user level setting of "Path" variable : 用户级别的“路径”变量设置: 用户级别的“路径”变量设置

System level setting of "Path" variable: 系统级别的“路径”变量的设置:

系统级别的“路径”变量设置

Installed JREs setting in Eclipse: 在Eclipse中安装的JRE设置: Eclipse中已安装的JRE设置

Eclipse2中已安装的JRE设置

Projects I tried to import was cloned from github, the repository url is https://github.com/scribejava/scribejava 我尝试导入的项目是从github克隆的,存储库URL是https://github.com/scribejava/scribejava

I had searched for an answer on internet for two days.. On the official website I found this: https://maven.apache.org/plugins/maven-eclipse-plugin/trouble-shooting/jdk-being-used-is-different-than-expected.html , but it also hasn't solved my problem. 我已经在互联网上搜索了两天的答案。在官方网站上,我发现了这个问题: https : //maven.apache.org/plugins/maven-eclipse-plugin/trouble-shooting/jdk-being-used-is -different-than-expected.html ,但是它也没有解决我的问题。

I have run maven install on the parent project after importing finished, there is no error on all stages. 导入完成后,我已经在父项目上运行了maven install,所有阶段都没有错误。 The error occurs just during the first importing progress. 该错误仅在首次导入过程中发生。 And it also goes well without any errors when I import project again in a new workspace after I remove checkstyle plugin in pom.xml. 而且,当我删除pom.xml中的checkstyle插件之后,在新的工作空间中再次导入项目时,它也进行得很好,没有任何错误。

So I guess that there maybe something wrong with the settings of my develop environment. 所以我想我的开发环境的设置可能有问题。 This error doesn't affect any further operations after running maven "install" on project manually, but I really want to know why this happened and it will be the best if I can get rid of it. 在项目上手动运行maven“ install”之后,此错误不会影响任何进一步的操作,但是我真的很想知道为什么会发生这种情况,并且如果我能摆脱它,那将是最好的。 Thanks! 谢谢!

I have solved the problem. 我已经解决了问题。 I checked all configurations again, then I noticed that there is a setting entry "C:\\ProgramData\\Oracle\\Java\\javapath" in Path variable of System Level which may be the causes of the problem. 我再次检查了所有配置,然后发现在System Level的Path变量中有一个设置条目“ C:\\ ProgramData \\ Oracle \\ Java \\ javapath”,这可能是问题的原因。 As I had never set that before. 因为我以前从未设置过。 I thought that it is added automatically by JRE installation process perhaps. 我认为它可能是由JRE安装过程自动添加的。 I run "where java" in cmd console, both "C:\\ProgramData\\Oracle\\Java\\javapath" and "C:\\Java\\jdk8\\bin" showed in result list with the "C:\\ProgramData\\Oracle\\Java\\javapath" entry on the top of list. 我在cmd控制台中运行“ where java”,结果列表中显示了“ C:\\ ProgramData \\ Oracle \\ Java \\ javapath”和“ C:\\ Java \\ jdk8 \\ bin”,并带有“ C:\\ ProgramData \\ Oracle \\ Java \\列表顶部的“ javapath”条目。 Finally all problems gone after I removing "C:\\ProgramData\\Oracle\\Java\\javapath" from Path Variable. 最后,从路径变量中删除“ C:\\ ProgramData \\ Oracle \\ Java \\ javapath”之后,所有问题都消失了。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM