【发布时间】:2021-04-24 16:14:33
【问题描述】:
在我的 POM 中,我将 Spring Boot 的版本从 2.3.5.RELEASE 升级到了 2.4.2。结果,mvn clean test 现在失败并出现错误
java.lang.NoClassDefFoundError: org/springframework/test/context/TestContextAnnotationUtils
Caused by: java.lang.ClassNotFoundException: org.springframework.test.context.TestContextAnnotationUtils
在一个简单的测试中
package ch.ge.ael.enu.mediation;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class MediationApplicationTests {
@Test
void contextLoads() {
}
}
有人知道吗?
【问题讨论】:
-
一般来说,要么你有一个损坏的测试 jar,要么正在混合来自不同版本的 Spring 的 jar。我怀疑是后者,而您正试图通过提供不必要的依赖项或版本标签来超越框架。
-
这篇文章可能会有所帮助。github.com/spring-projects/spring-boot/wiki/…
-
显示你的 pom.xml。没有它,所有的帮助都只是猜测。
-
非常感谢@M.Deinum,您的干预与十年前一样有用!
标签: spring-boot junit5 spring-test