使用maven install(编译)项目报错:html
[ERROR] Failed to execute goal on project basic-logic: Could not resolve dependencies for project com.basic.management:basic-logic:jar:1.1.0: Could not find artifact jdk.tools:jdk.tools:jar:1.8 at specified path D:\Program Files\JetBrains\IntelliJ IDEA 2018.1.5\jre64/../lib/tools.jar -> [Help 1]
maven install failed!maven
从异常信息看,与jkd的tools.jar包相关。故此从网上查阅了许多解决方案:ide
好比:修改编译失败的项目POM.XML文件,添加一下代码:ui
<dependency> <groupId>jdk.tools</groupId> <artifactId>jdk.tools</artifactId> <version>1.8</version> <scope>system</scope> <systemPath>${JAVA_HOME}/lib/tools.jar</systemPath> </dependency>
此方案能够解决项目打包是编译失败的问题,可是这样的解决方式存在风险和操做繁琐。idea
3.解决方案(较优)htm
idea中,找到设置jre的配置进行修改:blog
>> Settings >> Build tools >> Maven >> Runner ,修改JRE项的配置:选择项目依赖的JDK路径(通常选择User Internal JRE会致使找不到Tools.jar)ci
固然此配置操做,IDEA在配置SDK环境以后,加入项目时是自动配置好的,可是可能由其余操做致使此问题io