Starting from Spring 5, AsyncRestTemplate is deprecated in favour of WebClient from spring-webflux. One good thing is that you don’t have to use reactive async WebFlux in order to use WebClient. Instead, you can still use WebClient in a synchronous blocking way in Spring Web MVC so your existing projects can continue to work. When converting one of my existing applications from AsyncRestTemplate to WebClient, I found there wasn’t sufficient documentation or examples to do a quick replacement. After a bit of searching and learning by trial and error, here are the code snippets I came out eventually. Here is the code gist Reference : https://docs.spring.io/spring/docs/5.0.0.RELEASE/spring-framework-reference/web-reactive.html#webflux-client https://www.callicoder.com/spring-5-reactive-webclient-webtestclient-examples/ Create WebClient Requirements Create one WebClient bean for each service that requires specific configurations. Config timeout, such as c...
Share coding experience