macOS系统编译Maven项目时报错:Could not find artifact com.sun:tools:jar:1.5.0

在Mac上的终端输入命令 mvn clean package -e -U  进行项目的编译时,报错:

Could not resolve dependencies for project com.XXXX :jar:1.0-SNAPSHOT: Could not find artifact com.sun:tools:jar:1.5.0 at specified path /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/../lib/tools.jar 

导致 “BUILD FAILURE” 

    

 

  疯狂百度,试了很多很多方法呀!

法一:在pom.xml文件中添加依赖( https://blog.csdn.net/kobe269/article/details/39970793)——不行

法二:连上VPN也不行。
 

 还是无济于事……

————————————————————————

最后求助Colleague,需要在 pom.xml 文件中手动加入 以下内容:(直接将tools.jar的路径写死~不要用相对路径了)

(其中的systemPath为实际的jdk中tools.jar的路径)

   

 内容为:

        <dependency>
            <groupId>com.sun</groupId>
            <artifactId>tools</artifactId>
            <version>1.5.0</version>
            <scope>system</scope>
            <systemPath>/Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home/lib/tools.jar</systemPath>
        </dependency>

 

完了之后重新编译项目,mvn clean package -e -U

不会报之前那个错了,但是又出现了新的错误:
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK? 
 

posted on 2021-02-23 19:57  CuriousZero  阅读(1335)  评论(0编辑  收藏  举报

导航