Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 322
Ivan dal Bosco Avatar asked Jan 20 '21 09:01

Ivan dal Bosco


2 Answers

What resolved this issue for me was upgrading my spring-test dependency version from 5.2.9.RELEASE to 5.3.8

like image 130
Oozeerally Avatar answered Oct 24 '22 12:10

Oozeerally


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.

like image 38
Ivan dal Bosco Avatar answered Oct 24 '22 13:10

Ivan dal Bosco