javaspringspring-bootgradlespring-cloud

Spring Boot 3.0.11: java.lang.NoClassDefFoundError: org.springframework.cloud.test.TestSocketUtils


I am using the below given dependency in the build.gradle for application tests:

testImplementation 'org.springframework.cloud:spring-cloud-starter-contract-verifier:4.0.1'

Now when I updated the Spring Boot version from 2.x to 3.x, I am getting java.lang.NoClassDefFoundError for TestSocketUtils.

Wondering if anyone has got this issue before?


Solution

  • Please add spring-cloud-test-support dependency in build.gradle:

    testImplementation 'org.springframework.cloud:spring-cloud-test-support:4.0.1'
    

    This has the org.springframework.cloud.test.TestSocketUtils class in it.