找不到工件 com.sun:tools:jar:0

Could not find artifact 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]

我的 JDK 中没有 tools.jar(我有 jdk-11.0.2)。

我从 2H 开始,请帮忙:/

tools.jar 从 Java 9+

中移除

你在 JDK 11。那里找不到 tools.jar

JEP 220: Modular Run-Time Images removed both tools.jar and rt.jar from the lib folder, as of 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, a.k.a. 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 块。

请查阅 Maven 存储库以获取 Apache Maven Checkstyle Plugin and of Checkstyle.

的版本