有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java找不到工件com。sun:tools:jar:0

我试图通过执行mvn checkstyle:checkstyle来使用checkstyle和findbugs,但是出现了这个错误 This error

[ERROR] Failed to execute goal on project my-project: Could not resolve dependencies for project default:my-project:jar:1.1: Could not find artifact com.sun:tools:jar:0 at specified path C:\Program Files\Java\jdk-11.0.2/../lib/tools.jar -> [Help 1]

我没有工具。jar到我的JDK中(我有JDK-11.0.2)

我从2小时就开始了,请帮助:/


共 (1) 个答案

  1. # 1 楼答案

    tools.jar已从Java 9中删除+

    你在JDK 11上。没有找到tools.jar

    JEP 220: Modular Run-Time Imageslib文件夹中删除了tools.jarrt.jar,从Java 9开始

    Removed: rt.jar and tools.jar

    The class and resource files previously stored in lib/rt.jar, lib/tools.jar, lib/dt.jar, and various other internal JAR files are now stored in a more efficient format in implementation-specific files in the lib directory. The format of these files is not specified and is subject to change without notice.

    此更改是添加Java Platform Module System的一部分,也称为Project Jigsaw

    要升级Checkstyle,请使用更高版本,例如:

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-checkstyle-plugin</artifactId>
        <version>3.0.0</version>
        <dependencies>
            <dependency>
                <groupId>com.puppycrawl.tools</groupId>
                <artifactId>checkstyle</artifactId>
                <version>8.18</version>
            </dependency>
        </dependencies>
    </plugin>
    

    请注意内部的dependency

    有关Apache Maven Checkstyle PluginCheckstyle的版本,请咨询Maven repo