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

Jetty依赖版本不兼容:org.eclipse.jetty.server.handler.ScopedHandler缺失

问题根源与解决方案

你的问题核心是Jetty组件版本不匹配:同时使用jetty-server:12.0.3(Jetty 12大版本)和jetty-servlet:11.0.18(Jetty 11大版本),两个版本分属不同Jetty世代,内部API结构差异极大,导致ScopedHandler这类核心类无法被正确加载。

Jetty 12是基于Jakarta EE 9+(对应Servlet 6.0)的重大重构版本,很多内部Handler类的结构、包路径都做了调整;而Jetty 11对应Jakarta EE 8(Servlet 5.0),两者依赖完全不能混用。


解决方法:统一Jetty版本

方案1:升级所有Jetty组件到12.x(推荐,适配当前Servlet 6.0)

将jetty-servlet版本改为和jetty-server一致的12.0.3,修改后的Maven依赖如下:

<properties>
    <maven.compiler.source>20</maven.compiler.source>
    <maven.compiler.target>20</maven.compiler.target>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
    <dependency>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-server</artifactId>
        <version>12.0.3</version>
    </dependency>
    <dependency>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-servlet</artifactId>
        <version>12.0.3</version>
    </dependency>
    <dependency>
        <groupId>jakarta.servlet</groupId>
        <artifactId>jakarta.servlet-api</artifactId>
        <version>6.0.0</version>
        <scope>provided</scope>
    </dependency>
</dependencies>

方案2:降级所有Jetty组件到11.x(适配Servlet 5.0)

如果不想升级到Jetty 12,可将jetty-server版本改为11.0.18,同时把jakarta.servlet-api降级到5.0.0(Jetty 11对应的Servlet版本):

<properties>
    <maven.compiler.source>20</maven.compiler.source>
    <maven.compiler.target>20</maven.compiler.target>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
    <dependency>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-server</artifactId>
        <version>11.0.18</version>
    </dependency>
    <dependency>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-servlet</artifactId>
        <version>11.0.18</version>
    </dependency>
    <dependency>
        <groupId>jakarta.servlet</groupId>
        <artifactId>jakarta.servlet-api</artifactId>
        <version>5.0.0</version>
        <scope>provided</scope>
    </dependency>
</dependencies>

修改完成后执行mvn clean install刷新依赖,ServletHandler和依赖的ScopedHandler类就能正常加载了。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.06 08:28:25