You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
@royclarkson just let me know that the RestTemplate default constructor now comes with no MessageConverters, for performance reasons.
It's quite obvious that no one needs all the default converters, we usually only need one converter.
This change also means that by default, a @Rest annotated interface will come with en empty RestTemplate that will have no MessageConverter. To add one, we must do: restClient.getRestTemplate().getMessageConverters().add(new MappingJacksonHttpMessageConverter());
We should provide a new annotation (or a new attribute) to let users specify the MessageConverters.
We should check that they have a default constructor. We could also allow classes annotated with @EBean, but I'm not sure this would provide much added value for now.
It is still possible to create a new RestTemplate instance with the default set of converters by calling RestTemplate(true). As you note, there isn't a lot of need for loading all of these though. For reference, these are the default converters that are loaded:
ByteArrayHttpMessageConverter - Always included
StringHttpMessageConverter - Always included
ResourceHttpMessageConverter - Always included
SourceHttpMessageConverter - Included on Android 2.2 (Froyo) or newer, where javax.xml.transform.Source is available
XmlAwareFormHttpMessageConverter - same as previous
FormHttpMessageConverter - Included on Android 2.1 (Eclair) and older
SimpleXmlHttpMessageConverter - Included if the Simple XML serializer is present
MappingJacksonHttpMessageConverter - Included if the Jackson JSON processor is present
SyndFeedHttpMessageConverter - Included if the Android ROME Feed Reader is present
Thank your for those details. We could also detect the availability of the libs in the classpath at compile time and automatically add the converters in such a case, but I think we'd rather let the users fail early, find out that they need to add specific converters & libs, and then only add the needed ones.
I added a RestTemplate section to the documentation to document this new RestTemplate behavior. Thanks again for letting us know!
Well, since the default RestTemplate constructor is now the one that comes with no converters, there's no "two ways" here :) . They'll both use the same constructor.
@royclarkson just let me know that the RestTemplate default constructor now comes with no MessageConverters, for performance reasons.
It's quite obvious that no one needs all the default converters, we usually only need one converter.
This change also means that by default, a
@Restannotated interface will come with en empty RestTemplate that will have noMessageConverter. To add one, we must do:restClient.getRestTemplate().getMessageConverters().add(new MappingJacksonHttpMessageConverter());We should provide a new annotation (or a new attribute) to let users specify the MessageConverters.
We should check that they have a default constructor. We could also allow classes annotated with
@EBean, but I'm not sure this would provide much added value for now.