全局resttemp配置项
This commit is contained in:
parent
20dbf5753a
commit
718689b223
|
@ -1,5 +1,6 @@
|
||||||
package io.renren.common.config;
|
package io.renren.common.config;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.http.client.ClientHttpRequestFactory;
|
import org.springframework.http.client.ClientHttpRequestFactory;
|
||||||
|
@ -12,6 +13,11 @@ import java.nio.charset.Charset;
|
||||||
@Configuration
|
@Configuration
|
||||||
public class RestTemplateConfig {
|
public class RestTemplateConfig {
|
||||||
|
|
||||||
|
@Value("${rest_template.read_timeout}")
|
||||||
|
private Integer read_timeout;
|
||||||
|
@Value("${rest_template.connect_timeout}")
|
||||||
|
private Integer connect_timeout;
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public RestTemplate restTemplate(ClientHttpRequestFactory factory) {
|
public RestTemplate restTemplate(ClientHttpRequestFactory factory) {
|
||||||
RestTemplate restTemplate = new RestTemplate(factory);
|
RestTemplate restTemplate = new RestTemplate(factory);
|
||||||
|
@ -22,8 +28,8 @@ public class RestTemplateConfig {
|
||||||
@Bean
|
@Bean
|
||||||
public ClientHttpRequestFactory simpleClientHttpRequestFactory() {
|
public ClientHttpRequestFactory simpleClientHttpRequestFactory() {
|
||||||
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
|
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
|
||||||
factory.setReadTimeout(30 * 000);//单位为ms
|
factory.setReadTimeout(read_timeout);//单位为ms
|
||||||
factory.setConnectTimeout(5 * 1000);//单位为ms
|
factory.setConnectTimeout(connect_timeout);//单位为ms
|
||||||
factory.setOutputStreaming(false);
|
factory.setOutputStreaming(false);
|
||||||
|
|
||||||
// InetSocketAddress socketAddress = new InetSocketAddress("192.168.124.31", 8888);
|
// InetSocketAddress socketAddress = new InetSocketAddress("192.168.124.31", 8888);
|
||||||
|
|
|
@ -20,6 +20,10 @@ big_date:
|
||||||
census:
|
census:
|
||||||
type: 应用资源,组件服务,基础设施,数据资源,知识库
|
type: 应用资源,组件服务,基础设施,数据资源,知识库
|
||||||
applyType: 应用资源,业务组件,图层服务,开发组件,智能算法
|
applyType: 应用资源,业务组件,图层服务,开发组件,智能算法
|
||||||
|
# 全局RestTemplate配置
|
||||||
|
rest_template:
|
||||||
|
read_timeout: 30000
|
||||||
|
connect_timeout: 5000
|
||||||
# 海信网关
|
# 海信网关
|
||||||
hisense:
|
hisense:
|
||||||
gateway:
|
gateway:
|
||||||
|
|
Loading…
Reference in New Issue