Java Pom.xml 项目构建错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19921311/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 21:31:56  来源:igfitidea点击:

Pom.xml project build error

javaeclipsemavenmaven-3pom.xml

提问by Y0gesh Gupta

I have imported maven projects in my eclipse, but I am getting the following error in pom.xml-

我在 Eclipse 中导入了 Maven 项目,但是在 pom.xml- 中出现以下错误

Project build error: 'dependencyManagement.dependencies.dependency.systemPath' for jdk.tools:jdk.tools:jar must specify an absolute path but is ${JAVA_HOME}/lib/tools.jar

项目构建错误:'dependencyManagement.dependencies.dependency.systemPath' for jdk.tools:jdk.tools:jar 必须指定绝对路径,但为 ${JAVA_HOME}/lib/tools.jar

I am kind of new to maven, any help will be appreciated.

我对 maven 有点陌生,任何帮助将不胜感激。

采纳答案by Sam Hanes

You've specified a dependency on jdk.tools:jdk.tools:jarwith a <systemPath>of ${JAVA_HOME}/lib/tools.jar. ${JAVA_HOME}is not a valid Maven property. The syntax to read the environment variable JAVA_HOMEis ${env.JAVA_HOME}. However, the same information is exposed as a system propertynamed java.home, so ${java.home}is the best solution.

您已jdk.tools:jdk.tools:jar使用<systemPath>of指定了依赖项${JAVA_HOME}/lib/tools.jar${JAVA_HOME}不是有效的Maven 属性。读取环境变量的语法JAVA_HOME${env.JAVA_HOME}. 但是,相同的信息作为名为的系统属性公开java.home,因此${java.home}是最佳解决方案。

回答by Doss

Look for tools.jarwhich should be in jdk/lib, if not mean download latest jdk or add tools.jarto this location. This should fix the issue.

寻找tools.jar哪个应该在jdk/lib,如果不是意味着下载最新的 jdk 或添加tools.jar到这个位置。这应该可以解决问题。