after upgrading spring parent pom to 3.3.3 (from spring-boot-starter-parent 3.2.5) and having required test and webflux dependencies at a version of 3.3.3 Spring keeps throwing error: "org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.test.web.client.TestRestTemplate': org/springframework/web/client/NoOpResponseErrorHandler
"
Caused by: java.lang.NoClassDefFoundError: org/springframework/web/client/NoOpResponseErrorHandler
while starting unit tests with WebTestClient, switching back to previous parent pom fixed the issue. What could be the problem and how I could troubleshoot?
Don`t understand why is there even an attempt to create the TestRestTemplate bean...
Test class looks like following:
@SpringBootTest(webEnvironment = RANDOM_PORT, classes = MyServiceApplication.class)
public class MyClientTest {
@Autowired
private WebTestClient webTestClient;
@Test
....
}
With dependency in pom of:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
Spring test is at 6.1.6 and comes from parent pom
Tried to set the dependency version manually, did not help Tried to change the webEnvoronment to MOCK but it fails differently and don`t think is the right solution to begin with
Please check which is the version of spring-web
you are using, if there is an intermediate pom that specifies some versions of the artifacts; the NoOpResponseErrorHandler
class has been introduced in 6.1.7 and perhaps the latest webflux releases expect to have it available.
Anyway, be careful not to force "spring ecosystem" library versions, even if now the tests run, it is not a good practice to have this big variance in dependencies. You should analyze the project and try to have a "spring-boot-parent managed" approach.