Welcome to JiKe DevOps Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
613 views
in Technique[技术] by (71.8m points)

spring boot - Correct the classpath of your application so that it contains a single, compatible version of io.jsonwebtoken.SignatureAlgorithm

I have an issue. Tried to change the versions (like it says on the internet), but it didn't help.I get this error when i try to deploy project using docker composer

Problem:

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

Console:


APPLICATION FAILED TO START


Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

io.jsonwebtoken.security.Keys.hmacShaKeyFor(Keys.java:84)

The following method did not exist:

io.jsonwebtoken.SignatureAlgorithm.getMinKeyLength()I

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

Action:

Correct the classpath of your application so that it contains a single, compatible version of io.jsonwebtoken.SignatureAlgorithm

This is my 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>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

Please log in or register to answer this question.

1 Answer

0 votes
by (71.8m points)

According to the documentation you only need the following dependencies:

<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-api</artifactId>
    <version>0.11.2</version>
</dependency>

The missing class / method is Jwts.parserBuilder() still available but was probably moved between versions. Removing the import from the class and allowing your IDE to reimport it, should resolve this issue.

(see comments under question for context)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to JiKe DevOps Community for programmer and developer-Open, Learning and Share
...