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

加载网页时出现java.lang.ClassNotFoundException: org.unbescape.uri.UriEscape异常

解决java.lang.ClassNotFoundException: org.unbescape.uri.UriEscape异常

这个错误很典型——你用Thymeleaf的URL表达式th:action="@{/competitions/{id}(id=${competition.id})}"时,Thymeleaf需要依赖org.unbescape来处理URI转义,但它找不到对应的类。虽然你已经在pom.xml里加了依赖,但大概率是版本不兼容、依赖没生效或者冲突导致的,试试下面的解决方案:

  • 匹配Thymeleaf与unbescape的版本
    不同版本的Thymeleaf对unbescape的版本有明确要求:

    • Thymeleaf 3.1.x系列:建议使用unbescape 1.1.6.RELEASE及以上
    • Thymeleaf 3.0.x系列:对应unbescape 1.1.x系列
      你可以先确认项目中Thymeleaf的版本,然后调整pom.xml里的unbescape依赖。比如Thymeleaf 3.1.x的配置:
    <dependency>
        <groupId>org.unbescape</groupId>
        <artifactId>unbescape</artifactId>
        <version>1.1.6.RELEASE</version>
    </dependency>
    
  • 检查依赖作用域
    确保你的unbescape依赖没有设置test或provided作用域——这两个作用域会导致依赖在运行时不被加载。如果没写scope,默认就是compile,是正常的。

  • 清理并重建项目
    Maven缓存有时候会抽风,导致依赖没正确下载或生效。执行以下命令强制清理缓存并重新构建:

    mvn clean install -U
    

    或者在IDE里右键项目,选择「Maven」→「Reload Project」刷新依赖。

  • 排查依赖冲突
    可能有其他第三方依赖间接引入了旧版本的unbescape,覆盖了你添加的版本。用下面的命令查看依赖树,找出冲突的来源:

    mvn dependency:tree | grep unbescape
    

    如果发现多个版本的unbescape,在冲突的依赖里添加排除规则,比如:

    <dependency>
        <groupId>冲突依赖的groupId</groupId>
        <artifactId>冲突依赖的artifactId</artifactId>
        <exclusions>
            <exclusion>
                <groupId>org.unbescape</groupId>
                <artifactId>unbescape</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.20 07:22:03