【发布时间】:2021-04-14 07:08:24
【问题描述】:
我有一个问题。试图更改版本(就像它在互联网上所说的那样),但它没有帮助。当我尝试使用 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)
以下方法不存在:
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
它是从以下位置加载的:
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>
【问题讨论】:
-
删除 jjwt 工件。根据文档 (github.com/jwtk/jjwt#maven),您只需要 jjwt-api、jjwt-impl 和 jjwt-jackson
-
当我删除 jjwt 工件时,我的代码方法出现错误 Jwts.parserBuilder() not found 该方法仅存在于 jjwt
-
该方法可能在版本之间移动。在删除 jjwt 依赖项后,您可能希望删除旧的导入,并且您的 IDE 可能会找到正确的新导入。 Jwts 类仍然存在,方法也存在:github.com/jwtk/jjwt/blob/master/api/src/main/java/io/…
-
感谢您的回复,它对我有用
-
我提供了正确解决此问题的答案。
标签: spring-boot jjwt