Json webtoken 依赖项将不会在 pom.xml 中解析

Json webtoken dependency will not resolve in pom.xml

我目前正在开发一个 Spring 项目,这是我的新手,并且不知道为什么我从 maven 存储库获得的这种依赖性现在会自行解决。我尝试同时使用分离的依赖项(jjwt-api,等等)和粘贴在我下面的 pom.xml 中的依赖项,但它不会解析。如果有人能帮我解决这个问题,我将不胜感激。

Spring v2.6.4 Java JDK 17 错误消息:未找到依赖项 'com.auth0:java-jwt:3.18.3'

l version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.6.4</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.legacy-banking</groupId>
    <artifactId>legacyBankingAPI</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>legacyBankingAPI</name>
    <description>Demo project for Spring Boot</description>
    <properties>
        <java.version>17</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-oauth2-client</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
 ---------THIS IS THE DEPENDENCY IN QUESTION BELOW---------------------------
        <dependency>
            <groupId>com.auth0</groupId>
            <artifactId>java-jwt</artifactId>
            <version>3.18.3</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

MvnRepository page says, it's in the central repo, and the central repo link to the pom.xml of the dependency also works: https://repo1.maven.org/maven2/com/auth0/java-jwt/3.18.3/java-jwt-3.18.3.pom

那你有没有试过离线解决一次?解析失败也会缓存在您的本地 Maven 存储库中,因此您可能需要清理它。你可以尝试使用

mvn dependency:get -Dartifact=com.auth0:java-jwt:3.18.3

或者您手动清除缓存的“缺失”依赖项:转到您本地的 Maven 存储库(通常在 ~/.m2/repository),下降到 com/auth0/java-jwt 并删除里面的文件夹 3.18.3,然后 运行 你的 maven 再次构建。

我刚刚重新加载了 pom.xml 文件,它起作用了。