package com.ycl.config;
|
|
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Configuration;
|
import org.springframework.http.client.SimpleClientHttpRequestFactory;
|
import org.springframework.web.client.RestTemplate;
|
|
/**
|
* 设置RestTemplate超时时间,单位:毫秒
|
* 如这里设置为5s
|
*/
|
@Configuration
|
public class RestTemplateConfig {
|
|
@Bean
|
public RestTemplate restTemplate() {
|
SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
|
requestFactory.setConnectTimeout(1000 * 5);
|
requestFactory.setReadTimeout(1000 * 5);
|
return new RestTemplate(requestFactory);
|
}
|
|
}
|