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

Spring4升级Spring5后触发java.lang.NoSuchMethodError异常求助

Spring4升级Spring5后Thymeleaf报NoSuchMethodError异常解决

问题根源

java.lang.NoSuchMethodError是因为Thymeleaf核心库与thymeleaf-spring5适配库版本不匹配:

  • 当前使用3.1.1.RELEASE的thymeleaf核心包,但搭配的thymeleaf-spring5是3.0.15.RELEASE,两个版本的API存在差异,适配库调用了核心库中不存在的WebExpressionContext构造方法签名。

修复方案

将thymeleaf核心库与thymeleaf-spring5的版本统一为同系列稳定版本,以下两种配置任选其一:

方案一:使用3.1.x系列版本

<dependency>
    <groupId>org.thymeleaf</groupId>
    <artifactId>thymeleaf</artifactId>
    <version>3.1.1.RELEASE</version>
</dependency>
<dependency>
    <groupId>org.thymeleaf</groupId>
    <artifactId>thymeleaf-spring5</artifactId>
    <version>3.1.1.RELEASE</version>
</dependency>

方案二:使用3.0.x系列版本

<dependency>
    <groupId>org.thymeleaf</groupId>
    <artifactId>thymeleaf</artifactId>
    <version>3.0.15.RELEASE</version>
</dependency>
<dependency>
    <groupId>org.thymeleaf</groupId>
    <artifactId>thymeleaf-spring5</artifactId>
    <version>3.0.15.RELEASE</version>
</dependency>

注意事项

  • Thymeleaf官方明确要求:thymeleaf-springX适配库的版本必须与核心thymeleaf版本完全一致,否则会引发类、方法不兼容问题。
  • Spring版本升级时,需同步梳理所有相关依赖的兼容性,避免跨版本混搭。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.27 06:52:55