All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.garmin.config.RestTemplateConfig Maven / Gradle / Ivy

The newest version!
package com.garmin.config;

import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;
@Configuration
public class RestTemplateConfig {

    @Bean
    @ConditionalOnMissingBean(
            name = {"redisTemplate"}
    )
    public RestTemplate restTemplate(ClientHttpRequestFactory factory) {
        return new RestTemplate(factory);
    }

    @Bean
    @ConditionalOnMissingBean(
            name = {"simpleClientHttpRequestFactory"}
    )
    public ClientHttpRequestFactory simpleClientHttpRequestFactory() {
        SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
        factory.setReadTimeout(5000);//ms
        factory.setConnectTimeout(15000);//ms
        return factory;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy