Before we start to call the Twitter APIs, we want to create an instance of WebClient in a Spring way. It means we are looking for a way to inject the instance, using the Dependency Injection Pattern.
To achieve this, we can use the @Configuration annotation and create a WebClient instance, using the @Bean annotation to declare the bean for the Spring container. Let's do that:
package springfive.twittergathering.infra.webimport org.springframework.context.annotation.Beanimport org.springframework.context.annotation.Configurationimport org.springframework.web.reactive.function.client.WebClient@Configurationopen class WebClientProducer { @Bean open fun webClient(): WebClient? { return WebClient.create() } ...