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

哪个版本的maven-surefire-plugin兼容Spring Boot 3.3?遇类缺失错误

问题分析与解决方案

错误根源

你遇到的Error: class missing: org/apache/maven/plugin/surefire/log/api/ConsoleLogger,核心问题是手动添加的junit-paltform-surefire-provider依赖(注意拼写错误,应为junit-platform-surefire-provider)与新版Surefire插件不兼容。

这个Provider依赖是为Surefire 2.x版本设计的,而Surefire 3.x开始已原生内置对JUnit Platform的支持,不再需要额外引入该依赖。旧依赖会与Surefire 3.x的API冲突,导致找不到新的ConsoleLogger类。

兼容版本与修复步骤

Spring Boot 3.3.0官方推荐兼容的maven-surefire-plugin版本是3.2.5(即你当前配置的版本),只需修正插件配置即可解决问题:

  1. 移除插件内的junit-platform-surefire-provider依赖,因为Surefire 3.x已原生支持JUnit 5/JUnit Platform。
  2. 若项目继承了Spring Boot父pom(<parent>org.springframework.boot:spring-boot-starter-parent:3.3.0</parent>),可省略手动指定Surefire版本,父pom会自动管理兼容版本。

修正后的插件配置示例:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <!-- 未继承父pom时,指定3.2.5或3.3.0版本均可 -->
  <version>3.2.5</version>
</plugin>

补充说明

  • 若不依赖Spring Boot父pom的版本管理,直接指定3.2.5或3.3.0版本的Surefire插件,均可与Spring Boot 3.3.0兼容。
  • 确保JUnit相关依赖(如spring-boot-starter-test)使用Spring Boot 3.3.0提供的版本,避免JUnit版本与Surefire版本不匹配。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.23 09:33:16