Spring boot 更正应用程序的类路径,使其包含io.jsonwebtoken.SignatureAlgorithm的单个兼容版本

Spring boot 更正应用程序的类路径,使其包含io.jsonwebtoken.SignatureAlgorithm的单个兼容版本,spring-boot,jjwt,Spring Boot,Jjwt,我有个问题。尝试更改版本(就像它在internet上说的那样),但没有帮助。我在尝试使用docker composer部署项目时遇到此错误 问题: The method's class, io.jsonwebtoken.SignatureAlgorithm, is available from the following locations: jar:file:/app/libs/jjwt-0.9.1.jar!/io/jsonwebtoken/SignatureAlgorithm.class

我有个问题。尝试更改版本(就像它在internet上说的那样),但没有帮助。我在尝试使用docker composer部署项目时遇到此错误

问题:

The method's class, io.jsonwebtoken.SignatureAlgorithm, is available from the following 
 locations:
jar:file:/app/libs/jjwt-0.9.1.jar!/io/jsonwebtoken/SignatureAlgorithm.class
jar:file:/app/libs/jjwt-api-0.11.2.jar!/io/jsonwebtoken/SignatureAlgorithm.class
It was loaded from the following location:
    file:/app/libs/jjwt-0.9.1.jar
控制台:


应用程序无法启动


说明:

试图调用不存在的方法。从以下位置进行了尝试:

io.jsonwebtoken.security.Keys.hmacShaKeyFor(Keys.java:84)
file:/app/libs/jjwt-0.9.1.jar
以下方法不存在:

io.jsonwebtoken.SignatureAlgorithm.getMinKeyLength()I
该方法的类io.jsonwebtoken.SignatureAlgorithm可从以下位置获得:

jar:file:/app/libs/jjwt-0.9.1.jar!/io/jsonwebtoken/SignatureAlgorithm.class
jar:file:/app/libs/jjwt-api-0.11.2.jar!/io/jsonwebtoken/SignatureAlgorithm.class
它是从以下位置加载的:

io.jsonwebtoken.security.Keys.hmacShaKeyFor(Keys.java:84)
file:/app/libs/jjwt-0.9.1.jar
行动:

更正应用程序的类路径,使其包含io.jsonwebtoken.SignatureAlgorithm的单个兼容版本

这是我的pom.xml:

<dependency>
        <groupId>io.jsonwebtoken</groupId>
        <artifactId>jjwt-impl</artifactId>
        <version>0.11.2</version>
        <scope>runtime</scope>
    </dependency>

    <dependency>
        <groupId>io.jsonwebtoken</groupId>
        <artifactId>jjwt-jackson</artifactId>
        <version>0.11.2</version>
        <scope>runtime</scope>
    </dependency>

    <dependency>
        <groupId>io.jsonwebtoken</groupId>
        <artifactId>jjwt</artifactId>
        <version>0.9.1</version>
    </dependency>-->
    <dependency>
        <groupId>io.jsonwebtoken</groupId>
        <artifactId>jjwt-api</artifactId>
        <version>0.11.2</version>
    </dependency>

io.jsonwebtoken
jjwtimpl
0.11.2
运行时
io.jsonwebtoken
杰克森
0.11.2
运行时
io.jsonwebtoken
jjwt
0.9.1
-->
io.jsonwebtoken
JJWTAPI
0.11.2
根据,您只需要以下依赖项:


io.jsonwebtoken
但可能在不同版本之间移动。从类中删除导入并允许IDE重新导入应该可以解决此问题


(请参阅问题下的注释了解上下文)

删除jjwt工件。根据文档()您只需要jjwt api、jjwt impl和jjwt Jackson当我删除jjwt工件时,我的代码方法Jwts中出现错误。parserBuilder()未发现该方法仅存在于jjwt中该方法可能在版本之间移动。您可能希望在删除jjwt依赖项后删除旧导入,并且IDE可能会找到正确的新导入。Jwts类仍然存在,方法也仍然存在:thx for your reply it work for meI提供了正确解决此问题的答案。