最近我一直在从事测试自动化的工作。
现在我已经熟悉了几种工具、框架、依赖项等,比如Selenium、JUNits、TestNG等,它们帮助我作为QA工程师管理我的日常工作。
我经常使用Selenium和TestNG来构建我的解决方案,还有在运行最新JDK版本(jdk-15.0.1)的IntelliJ IDEA上运行的MacOS Catalina Version 10.15.7。
我已经为我的项目配置好了POM.xml文件,并且自始至终在控制台上显示以下错误:
Cannot resolve com.sun:tools:0
我一直忽略它,因为我的IDE中的项目总是编译和运行,并且因为我从来没有使用过这个依赖项。但是现在我正在尝试从Mac终端用Maven支持运行我的项目,由于sun:tools.jar依赖关系,我无法编译到目前为止开发的任何工作项目。
我阅读了很多类似问题的相似线程,例如:
- Missing artifact com.sun:tools:jar
- Missing Library com.sun.tools.attach
- Could not find artifact com.sun:tools:jar:0
我已经尝试了所有方法,但许多解决方案都是在jdk安装目录中找到tools.jar文件。由于我正在使用JDK 15,此依赖项已被删除:
已删除:rt.jar和tools.jar
以前存储在lib/rt.jar、lib/tools.jar、lib/dt.jar和各种其他内部JAR文件中的类和资源文件现在以更高效的格式存储在实现特定的文件中,在lib目录中。这些文件的格式未指定,并且可能随时更改而不另行通知。
我附上终端显示的确切错误信息:
----------------------< org.example:YelpExercise >----------------------
[INFO] Building YelpExercise 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.737 s
[INFO] Finished at: 2020-11-04T18:59:47-03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project YelpExercise: Could not resolve dependencies for project org.example:YelpExercise:jar:1.0-SNAPSHOT: Could not find artifact com.sun:tools:jar:0 at specified path /Library/Java/JavaVirtualMachines/jdk-15.0.1.jdk/Contents/Home/../lib/tools.jar -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
tools.jar
,但自 JDK 9+ 起已将其移除,因此如果在 JDK 9+ 下运行 Maven,则会出现此错误。 - Andrey