我有一个Java项目,它依赖于SpringBoot版本2.3.6.RELEASE,但是我很难升级到2.4.0版本。在该项目中,没有其他任何更改,只有SpringBoot的版本。从那时起,应用程序抛出以下错误消息:
Caused by: java.lang.ClassCastException: com.nimbusds.jose.shaded.json.JSONObject cannot be cast to net.minidev.json.JSONObject我对maven依赖树(mvn dependency:tree)做了一些比较,发现可能已经对nimbus-jose-jwt和json智能库做了一些重要的更改。
2.3.6.RELEASE
[INFO] +- org.springframework.security:spring-security-oauth2-jose:jar:5.3.5.RELEASE:compile
[INFO] | +- com.nimbusds:nimbus-jose-jwt:jar:8.19:compile (version managed from 8.20.1)
[INFO] | | +- com.github.stephenc.jcip:jcip-annotations:jar:1.0-1:compile
[INFO] | | \- net.minidev:json-smart:jar:1.3.1:provided (scope managed from compile)
[INFO] | +- org.springframework.security:spring-security-core:jar:5.3.5.RELEASE:compile2.4.0
[INFO] +- org.springframework.security:spring-security-oauth2-jose:jar:5.4.1:compile
[INFO] | +- com.nimbusds:nimbus-jose-jwt:jar:9.1.2:compile (version managed from 9.0.1)
[INFO] | | \- com.github.stephenc.jcip:jcip-annotations:jar:1.0-1:compile
[INFO] | +- org.springframework.security:spring-security-core:jar:5.4.1:compile如上文所示,nimbus-jose-jwt已经从8.19更新到9.1.2。此外,在2.4.0中,nimbus-jose-jwt不再是json智能的一部分。
根本原因可能是这个改变https://connect2id.com/blog/nimbus-jose-jwt-9,但是,应该做什么来防止这种异常?
发布于 2020-11-26 02:31:13
您可以通过在pom中显式地添加旧版本来覆盖jars、nimbus、jose-jwt和json智能的默认版本。
发布于 2021-12-23 13:14:03
请参阅此处:https://github.com/Azure/azure-sdk-for-java/issues/14898
在我的例子中,我必须升级到2.5.7 Springboot版本,而nimbus-jose-jwt:jar版本是SB-2.5.7是9.10.1。
org.springframework.security:spring-security-oauth2-jose:jar:5.5.3:compile
[INFO] | +- (org.springframework.security:spring-security-core:jar:5.5.3:compile - version managed from 4.2.15.RELEASE; omitted for duplicate)
[INFO] | +- (org.springframework.security:spring-security-oauth2-core:jar:5.5.3:compile - omitted for duplicate)
[INFO] | +- (org.springframework:spring-core:jar:5.3.13:compile - version managed from 5.3.11; omitted for duplicate)
[INFO] | \- com.nimbusds:nimbus-jose-jwt:jar:9.10.1:compile在将nimbus-jose-jwt的评级下调至8.20之后,该应用程序开始工作。
https://stackoverflow.com/questions/65012506
复制相似问题