![](https://img-blog.csdnimg.cn/img_convert/8ea03deed70b4bb399d286f6d90fc1d5.png)
![](https://img-blog.csdnimg.cn/img_convert/d87e8478674047b3b01beff99835b34f.png)
![](https://img-blog.csdnimg.cn/img_convert/27e2e4647a414b979d84e732291cf004.png)
1、通过找正常能使用的项目pom文件,打开依赖视图找到junit-jupiter的依赖项spring-boot-starter-test(即spring-boot-starter-test的依赖pom文件中聚合了junit-jupiter的依赖)
![](https://img-blog.csdnimg.cn/img_convert/bc9975159b1c42ac8756efdcc486ebc4.png)
2、再查看报错项目的spring-boot-starter-test依赖,发现2.1.3.RELEASE版本集成的是junit的依赖,说明版本过低(旧版的spring-boot-starter-test使用的是junit的测试依赖)
//这两个测试类不一样的
import org.junit.Test;
import org.junit.jupiter.api.Test;
/**
* org.junit.Test;
* 这个是旧版JUnit4,SpringBoot在2.3.X及之前(<=2.3.12.RELEASE)集成该依赖
* org.junit.jupiter.api.Test;
* 这个是新版JUnit5,SpringBoot在2.4.X及之后(>=2.4.0)集成该依赖
*/
3、指定<version>覆盖掉项目版本默认的或父工程中的版本即可(通常开发中,版本号是统一抽离到顶级父pom文件中的<properties> 定义,使用{xxx}引用的,方便管理:统一更新)