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

升级Spring Boot至3.2.2后集成测试无法正常运行

Spring Boot 3.2.2集成测试启动失败问题

问题描述

我们基于Spring Boot测试框架编写了集成测试,在测试上下文初始化完成后,通过TestRestTemplate发起HTTP调用。该测试在Spring Boot 3.1.2版本下运行正常,但升级到3.2.2版本后无法执行,核心报错为java.lang.IncompatibleClassChangeError: class org.eclipse.jetty.http2.server.HttpChannelOverHTTP2 has interface org.eclipse.jetty.server.HttpChannel as super class。

错误栈

java.lang.IllegalStateException: Failed to load ApplicationContext for [WebMergedContextConfiguration@42cb8174 testClass = ["org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true"], contextCustomizers = [org.springframework.boot.test.autoconfigure.actuate.observability.ObservabilityContextCustomizerFactory$DisableObservabilityContextCustomizer@1f, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizer@73a0f2b, org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@687e6293, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@7e4579c7, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer@769bd849, org.springframework.boot.test.context.SpringBootTestAnnotation@804fcdb7], resourceBasePath = "src/main/webapp", contextLoader = org.springframework.boot.test.context.SpringBootContextLoader, parent = null]
    at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:180)
    ...
Caused by: java.lang.IncompatibleClassChangeError: class org.eclipse.jetty.http2.server.HttpChannelOverHTTP2 has interface org.eclipse.jetty.server.HttpChannel as super class
    ...

项目配置

build.gradle

plugins {
    id 'java'
    id 'org.springframework.boot' version "${springBootVersion}"
    id 'io.spring.dependency-management' version "${springDependencyVersion}"
    id "jacoco"
    id 'project-report'
    id "org.sonarqube" version "4.4.1.3373"
}

group = "${groupName}"
version = "${applicationVersion}"
sourceCompatibility = JavaVersion.VERSION_17
...

gradle.properties

springCloudVersion=2023.0.0
testContainerVersion=1.18.3
jacocoVersion=0.8.9
springBootVersion=3.2.2
springDependencyVersion=1.1.4

本地Java版本

openjdk 17.0.2 2022-01-18
OpenJDK Runtime Environment (build 17.0.2+8-86)
OpenJDK 64-Bit Server VM (build 17.0.2+8-86, mixed mode, sharing)

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.01 14:00:06