You need to include reactor-netty on the classpath. As by default that is the HTTP client used by WebClient.
pom.xml:
<dependency>
<groupId>io.projectreactor.netty</groupId>
<artifactId>reactor-netty</artifactId>
</dependency>
More info: https://docs.spring.io/spring/docs/current/spring-framework-reference/web-reactive.html#webflux-client
Answer from Martin Tarjányi on Stack Overflowspring boot - Webclient maven Dependency errors - Stack Overflow
maven - Could not resolve dependencies for spring-web-reactive - Stack Overflow
spring boot - Bean of type 'org.springframework.web.reactive.function.client.WebClient' that could not be found - Stack Overflow
Correct dependencies to use when using WebClient with Spring MVC - Stack Overflow
You need to include reactor-netty on the classpath. As by default that is the HTTP client used by WebClient.
pom.xml:
<dependency>
<groupId>io.projectreactor.netty</groupId>
<artifactId>reactor-netty</artifactId>
</dependency>
More info: https://docs.spring.io/spring/docs/current/spring-framework-reference/web-reactive.html#webflux-client
No worry option would be adding
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
spring-web-reactive is the former name of the module, that was changed during the Spring Framework 5.0 milestones. As shown by the link you're mentioning, those artifacts were never available on maven central but only on a Spring artifact repository.
If you take a look at the Spring Boot reference documentation, you'll see that spring-boot-starter-webflux is the dependency to add to your application to pick up spring-webflux, which is the module name for the reactive web support in Spring Framework.
Note that because you've got spring-boot-starter-web already in your application, your application will remain a Spring MVC application if you add the webflux starter, as stated in the reference documentation. There's nothing wrong with that, as Spring MVC supports reactive types in the controller signatures in some cases. It all boils down to what you're trying to achieve here.
You should update the dependency like this: Gradle/Grails
compile 'org.springframework.boot:spring-boot-starter-webflux:2.6.1'
See if any more details: maven central repository
There is no WebClient registered as bean.
You can simply use it like this:
WebClient.create().get().uri("http://api.icndb.com/jokes/random")
.retrieve().bodyToMono(IcndbJoke.class).block();
Or you use it like described in the Spring Boot Reference Manual
@Service
public class MyService {
private final WebClient webClient;
public MyService(WebClient.Builder webClientBuilder) {
this.webClient = webClientBuilder.baseUrl("https://example.org").build();
}
public Mono<Details> someRestCall(String name) {
return this.webClient.get().uri("/{name}/details", name)
.retrieve().bodyToMono(Details.class);
}
}
See: https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#io.rest-client.webclient
You should config the bean in the Configuration Class. For example:
@Configuration
class Configuration{
@Bean
WebClient webClient(WebClient.Builder builder) {
return builder.build();
}
}
And then you could use the webClient dependency in other class. For Example:
class otherClass{
private WebClient client;
//Your use
}