imbyungjun / spring-boot-rest-template-okhttp

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

spring-boot-rest-template-okhttp

Step 1. Add okhttp3 dependency

build.gradle

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'com.squareup.okhttp3:okhttp'
    ...
}

Step 2. Add customized RestTemplate bean

@Configuration
public class RestTemplateConfig {
    @Bean
    public RestTemplate restTemplate() {
        return new RestTemplateBuilder()
                .requestFactory(OkHttp3ClientHttpRequestFactory::new)
                .build();
    }
}

About


Languages

Language:Java 100.0%