Migrate RestTemplate constructor calls to RestClient

Proprietary

Migrates Spring's RestTemplate constructor invocations to the modern RestClient API introduced in Spring Framework 6.1. RestClient provides a fluent, synchronous API that is the recommended approach. new RestTemplate() becomes RestClient.create(), while new RestTemplate(ClientHttpRequestFactory) and new RestTemplate(List<HttpMessageConverter<?>>) become RestClient.builder() calls, as RestClient is an interface. RestTemplate is retyped to RestClient too, so that the result is assignable.

io.moderne.java.spring.boot3.MigrateToRestClientConstructor
mod run . --recipe=io.moderne.java.spring.boot3.MigrateToRestClientConstructor

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.

Recipe list

It runs these recipes, in this order.

  1. Change type RestTemplate to RestClient