Tested converting an existing integration test that was using TestRestTemplate into integration test using WebTestClient

package no.mycompany.myapp.user;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.web.reactive.server.WebTestClient;

@AutoConfigureWebTestClient
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class LoginControllerTest {

    @Autowired
    WebTestClient webTestClient;
        
    @Test
    public void postLogin_withoutUserCredentials_receiveUnauthorized() {
        webTestClient.post()
                .uri("/login")
                .exchange()
                .expectStatus().isUnauthorized();
    }
}

Added this to POM

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-webflux</artifactId>
        <scope>test</scope>
    </dependency>

The following was already in POM

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
Answer from Roar S. on Stack Overflow
🌐
Baeldung
baeldung.com › home › spring › spring web › spring webclient
Spring WebClient | Baeldung
November 25, 2025 - Since we are using a Spring Boot application, all we need is the spring-boot-starter-webflux dependency to obtain Spring Framework’s Reactive Web support.
🌐
josdem
josdem.io › home › spring boot web client
Spring Boot WebClient -
July 25, 2024 - buildscript { ext { springBootVersion = '2.1.0.RELEASE' } repositories { mavenCentral() } dependencies { classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") } } apply plugin: 'java' apply plugin: 'org.springframework.boot' apply plugin: 'io.spring.dependency-management' group = 'com.jos.dem.springboot.webclient' version = '0.0.1-SNAPSHOT' sourceCompatibility = 1.8 repositories { mavenCentral() } dependencies { implementation('org.springframework.boot:spring-boot-starter-webflux') compileOnly('org.projectlombok:lombok') testImplementation('org.springframework.boot:spring-boot-starter-test') testImplementation('io.projectreactor:reactor-test') }
🌐
amitph
amitph.com › home › spring › introduction to spring webclient
Introduction to Spring WebClient - amitph
November 22, 2024 - Like any other Spring Boot dependencies, we have to add a starter dependency for WebFlux (spring-boot-starter-webflux). For Maven built projects, add the starter dependency for WebClient in pom.xml File.
🌐
GeeksforGeeks
geeksforgeeks.org › springboot › spring-boot-webclient-with-example
Spring Boot - WebClient with Example - GeeksforGeeks
July 23, 2025 - dependencies { compile 'org.springframework.boot:spring-boot-starter-webflux' } After adding the library create Bean for WebClient in the configuration file like below
🌐
Spring
docs.spring.io › spring-boot › docs › 2.1.x › reference › html › boot-features-webclient.html
37. Calling REST Services with WebClient
The spring-boot-starter-webflux starter depends on io.projectreactor.netty:reactor-netty by default, which brings both server and client implementations. If you choose to use Jetty as a reactive server instead, you should add a dependency on the Jetty Reactive HTTP client library, org.eclipse.jetty:jetty-reactive-httpclient.
Find elsewhere
🌐
GitHub
github.com › openrewrite › rewrite-spring › issues › 872
Add missing WebClient Spring Boot Starter (Spring Boot 4) · Issue #872 · openrewrite/rewrite-spring
December 15, 2025 - add dependency spring-boot-starter-webclient-test if org.springframework.web.reactive.function.client.WebClient is used in project
Author: openrewrite
🌐
Home
gustavopeiretti.com › home › spring boot how to use web client
Spring Boot - How to use WebClient - Home - Gustavo Peiretti
October 26, 2020 - spring-boot-starter-webflux is the necessary dependency for the webclient
🌐
NashTech Blog
blog.nashtechglobal.com › home › introduction to spring webclient
Introduction to Spring WebClient - NashTech Blog
February 22, 2023 - In order to use WebClient in our Spring Boot project, we need to add a dependency on the WebFlux library.
🌐
Medium
medium.com › @bwang.fdu › using-webclient-in-spring-webmvc-be13f13ac26a
Using WebClient in Spring WebMVC. WebClient is another non-blocking HTTP… | by bwang | Medium
March 19, 2024 - WebClient is another non-blocking HTTP client introduced in Spring WebFlux framework. It is the default http client using in the Spring…
🌐
Maven Central
central.sonatype.com › artifact › org.springframework.boot › spring-boot-starter-webclient
Maven Central: org.springframework.boot:spring-boot-starter-webclient
Dependencies · Starter using Spring's reactive HTTP clients (WebClient and HTTP Service Clients) Copy to clipboard · <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-webclient</artifactId> <version>4.2.0-M1</version> </dependency> Copy to clipboard ·
🌐
Medium
medium.com › @ayoubseddiki132 › mastering-webclient-in-spring-boot-a-complete-guide-31482263bc92
Mastering WebClient in Spring Boot: A Complete Guide | by Ayoub seddiki | Medium
January 29, 2025 - WebClient is a part of the Spring WebFlux module and provides a reactive, non-blocking API to perform HTTP requests. Unlike RestTemplate, which blocks the thread while waiting for a response, WebClient operates asynchronously, making it ideal ...
🌐
Medium
selvaseamers.medium.com › a-comprehensive-guide-to-using-webclient-in-java-spring-configuring-client-oauth2-custom-5beb686ab7d1
A Comprehensive Guide to Using WebClient in Java Spring: Configuring Client OAuth2, Custom…
April 3, 2023 - <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-webflux</artifactId> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-oauth2-client</artifactId> </dependency> With these dependencies added, we can now define our WebClient bean with the required configurations:
🌐
Spring
docs.spring.io › spring-boot › docs › 2.1.8.RELEASE › reference › html › boot-features-webclient.html
36. Calling REST Services with WebClient
The spring-boot-starter-webflux starter depends on io.projectreactor.netty:reactor-netty by default, which brings both server and client implementations. If you choose to use Jetty as a reactive server instead, you should add a dependency on the Jetty Reactive HTTP client library, org.eclipse.jetty:jetty-reactive-httpclient.
🌐
Stefankreidel
stefankreidel.io › blog › spring-webmvc-with-webclient
Spring Web MVC + WebClient: How they work Together – Stefan Kreidel
You simply have to add both, Web and Webflux as dependencies. This will start Spring in the “classic” Web MVC stack with Tomcat as servlet container as we discussed in the dedicated Web MVC post.
🌐
Reflectoring
reflectoring.io › spring-webclient
Sending HTTP requests with Spring WebClient
May 25, 2021 - The Spring WebClient API must be used on top of an existing asynchronous HTTP client library. In most cases that will be Reactor Netty, but you can also use Jetty Reactive HttpClient or Apache HttpComponents, or integrate others by building ...
🌐
GitHub
github.com › spring-projects › spring-boot › issues › 34198
How can I get a WebClient without a required dependency to any web server? · Issue #34198 · spring-projects/spring-boot
February 15, 2023 - I want to use a Flux WebClient in a reuse-library. This library is a web-client only and should not include any http-server component. My library is to be used in console / shell applications, which also have no use for any http-server component. I know that It is possible to configure the http-client. But it seems, you can not have the http-client without the server. If I take out the dependency to the webflux-starter, and work with the spring-webflux dependency only, I get the error message:
Author: spring-projects