You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Azure AD登录成功后重定向至Spring Boot应用报NoSuchMethodError求助

问题根因

该问题为典型的依赖版本不兼容导致的Jar包冲突,和配置无关。
你遇到的错误:

java.lang.NoSuchMethodError: org.springframework.security.oauth2.client.endpoint.OAuth2AuthorizationCodeGrantRequestEntityConverter.convert(Lorg/springframework/security/oauth2/client/endpoint/OAuth2AuthorizationCodeGrantRequest;)Lorg/springframework/http/RequestEntity;

本质是方法签名不匹配:你当前使用的spring-security-oauth2-client 5.5.0版本中,convert方法的返回值为HttpEntity,而azure-spring-boot-starter-active-directory 3.5.0依赖的该方法返回值为RequestEntity,JVM无法找到匹配的方法因此抛出错误。

解决方案
  • 方案一:降级Spring Boot版本至2.4.x系列(推荐使用2.4.13稳定版),该版本自带的spring-security-oauth2-client版本为5.4.x,和azure-spring-boot-starter-active-directory 3.5.0完全兼容,无需额外调整依赖版本。
  • 方案二:升级azure-spring-boot-starter-active-directory版本至3.8.0及以上,该版本及后续版本已完成对Spring Boot 2.5.x的适配,可匹配你当前使用的Spring Boot 2.5.0版本。
  • 方案三:强制锁定spring-security-oauth2-client版本为5.4.x系列(如5.4.9),在依赖配置中显式声明该依赖的版本覆盖Spring Boot父pom自带的版本即可,该方案不推荐使用,可能引发其他Spring Security相关的兼容性问题。
通用排查技巧
  • 后续遇到NoSuchMethodError、ClassNotFoundException这类错误优先排查依赖版本兼容性,可通过mvn dependency:tree(Maven项目)或gradlew dependencies(Gradle项目)命令查看实际引入的依赖版本,确认是否存在同依赖多版本冲突的情况。

内容的提问来源于stack exchange,提问作者IamVenkatReddy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.25 15:54:04