Search in sources :

Example 1 with HttpMessageConverters

use of org.springframework.boot.autoconfigure.http.HttpMessageConverters in project spring-boot by spring-projects.

the class RestTemplateAutoConfiguration method restTemplateBuilder.

@Bean
@ConditionalOnMissingBean
public RestTemplateBuilder restTemplateBuilder() {
    RestTemplateBuilder builder = new RestTemplateBuilder();
    HttpMessageConverters converters = this.messageConverters.getIfUnique();
    if (converters != null) {
        builder = builder.messageConverters(converters.getConverters());
    }
    List<RestTemplateCustomizer> customizers = this.restTemplateCustomizers.getIfAvailable();
    if (!CollectionUtils.isEmpty(customizers)) {
        customizers = new ArrayList<>(customizers);
        AnnotationAwareOrderComparator.sort(customizers);
        builder = builder.customizers(customizers);
    }
    return builder;
}
Also used : RestTemplateBuilder(org.springframework.boot.web.client.RestTemplateBuilder) RestTemplateCustomizer(org.springframework.boot.web.client.RestTemplateCustomizer) HttpMessageConverters(org.springframework.boot.autoconfigure.http.HttpMessageConverters) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 2 with HttpMessageConverters

use of org.springframework.boot.autoconfigure.http.HttpMessageConverters in project tutorials by eugenp.

the class Spring5Application method customConverters.

@Bean
public HttpMessageConverters customConverters() {
    Collection<HttpMessageConverter<?>> messageConverters = new ArrayList<>();
    JsonbHttpMessageConverter jsonbHttpMessageConverter = new JsonbHttpMessageConverter();
    messageConverters.add(jsonbHttpMessageConverter);
    return new HttpMessageConverters(true, messageConverters);
}
Also used : JsonbHttpMessageConverter(org.springframework.http.converter.json.JsonbHttpMessageConverter) HttpMessageConverter(org.springframework.http.converter.HttpMessageConverter) JsonbHttpMessageConverter(org.springframework.http.converter.json.JsonbHttpMessageConverter) ArrayList(java.util.ArrayList) HttpMessageConverters(org.springframework.boot.autoconfigure.http.HttpMessageConverters) Bean(org.springframework.context.annotation.Bean)

Aggregations

HttpMessageConverters (org.springframework.boot.autoconfigure.http.HttpMessageConverters)2 Bean (org.springframework.context.annotation.Bean)2 ArrayList (java.util.ArrayList)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 RestTemplateBuilder (org.springframework.boot.web.client.RestTemplateBuilder)1 RestTemplateCustomizer (org.springframework.boot.web.client.RestTemplateCustomizer)1 HttpMessageConverter (org.springframework.http.converter.HttpMessageConverter)1 JsonbHttpMessageConverter (org.springframework.http.converter.json.JsonbHttpMessageConverter)1