Search code examples
spring-bootjunit5spring-test

ClassNotFoundException on org.springframework.test.context.TestContextAnnotationUtils when upgrading Spring Boot to 2.4.2


In my POM I upgraded the version of Spring Boot from 2.3.5.RELEASE to 2.4.2. As a result, mvn clean test now fails with error

java.lang.NoClassDefFoundError: org/springframework/test/context/TestContextAnnotationUtils
Caused by: java.lang.ClassNotFoundException: org.springframework.test.context.TestContextAnnotationUtils

on a test that consists simply in

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() {
    }

}

Does anyone have a clue?


Solution

  • Marten Deinum's comment was correct : a dependency created havoc among the Spring JARs' versions. With Camel 3.6.0, Spring Boot 2.3.5.RELEASE was OK but Spring Boot 2.4.2 was not. Upgrading Camel to 3.7.1 did the trick.