diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/reactive/server/WebTestClientContextCustomizerFactory.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/reactive/server/WebTestClientContextCustomizerFactory.java index b8d4216640c7..8582af1bb3e5 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/reactive/server/WebTestClientContextCustomizerFactory.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/reactive/server/WebTestClientContextCustomizerFactory.java @@ -39,7 +39,7 @@ public ContextCustomizer createContextCustomizer(Class testClass, List configAttributes) { SpringBootTest springBootTest = TestContextAnnotationUtils.findMergedAnnotation(testClass, SpringBootTest.class); - return (springBootTest != null) ? new WebTestClientContextCustomizer() : null; + return (springBootTest != null && isWebClientPresent()) ? new WebTestClientContextCustomizer() : null; } private boolean isWebClientPresent() {