What is the difference between:
- RestTemplate created with
new
:
var t = new RestTemplate();
- RestTemplate created with the auto-configured RestTemplateBuilder
@Autowired
RestTemplateBuilder builder;
...
public void xyz() {
var t = builder.build();
}
- RestTemplate created from a new RestTemplateBuilder:
var t = new RestTemplateBuilder().build();
According to
Spring Documentation:
Spring Boot does not provide any single auto-configured RestTemplate bean. It does, however, auto-configure a RestTemplateBuilder, which can be used to create RestTemplate instances when needed. The auto-configured RestTemplateBuilder ensures that sensible HttpMessageConverters and an appropriate ClientHttpRequestFactory are applied to RestTemplate instances.
But what are the additional HttpMessageConverters
added?
And should #1 and #2 return RestTemplate
with the exact same configuration?