Spring Boot 3.4.0升级后Gradle测试执行失败问题求助
问题解决:Spring Boot 3.4.0升级后测试执行失败
错误原因
升级Spring Boot到3.4.0后,spring-boot-gradle-plugin版本仍停留在3.3.6,导致JUnit Platform相关依赖版本不匹配,缺失org.junit.platform.launcher.TestExecutionListener类,进而引发测试执行异常。
解决方案
- 同步Spring Boot Gradle插件版本:将父
build.gradle中的插件版本改为3.4.0,确保插件与Spring Boot核心版本一致:dependencies { classpath("org.springframework.boot:spring-boot-gradle-plugin:3.4.0") classpath 'org.owasp:dependency-check-gradle:8.2.1' } - 清理冗余依赖:
spring-boot-starter-test已经包含junit-jupiter,可移除重复的testImplementation("org.junit.jupiter:junit-jupiter"),避免版本冲突://Testing testImplementation 'org.springframework.boot:spring-boot-starter-test' - 刷新依赖并重新执行测试:执行Gradle的
clean和test任务,确保依赖更新生效。
内容的提问来源于stack exchange,提问作者saravanan Mk
相关产品推荐
相关产品推荐

