Springboot 测试启动报错 java.lang.ClassNotFoundException: org.springframework.test.context.TestContextAnnotationUtils

发布时间 2023-03-29 10:00:02作者: 烤乳鸽

在启动SpringBoot测试用例时报错:

 

 原因:

版本不一致

 

 在pom.xml中没有写明版本,spring-test 使用的5.2.10版本

解决: 

1、将spring-boot-test  和  spring-boot-start-test  版本统一为2.3.5

 

 2、去掉pom.xml 中对spring-testt 的版本限制

 

 可以看到取消掉之后用的5.3.20的版本

 

 

总结:

1、最好让spring-boot-***的版本都保持一致

2、spring-boot升级之后,spring-test的版本也要相应升级,直接取消版本限制即可

最后可以看到,spring-***   和spring-boot-***的版本都保持一致