全局resttemp配置项

This commit is contained in:
wangliwen 2022-11-11 09:25:32 +08:00
parent 20dbf5753a
commit 718689b223
2 changed files with 12 additions and 2 deletions

View File

@ -1,5 +1,6 @@
package io.renren.common.config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.ClientHttpRequestFactory;
@ -12,6 +13,11 @@ import java.nio.charset.Charset;
@Configuration
public class RestTemplateConfig {
@Value("${rest_template.read_timeout}")
private Integer read_timeout;
@Value("${rest_template.connect_timeout}")
private Integer connect_timeout;
@Bean
public RestTemplate restTemplate(ClientHttpRequestFactory factory) {
RestTemplate restTemplate = new RestTemplate(factory);
@ -22,8 +28,8 @@ public class RestTemplateConfig {
@Bean
public ClientHttpRequestFactory simpleClientHttpRequestFactory() {
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
factory.setReadTimeout(30 * 000);//单位为ms
factory.setConnectTimeout(5 * 1000);//单位为ms
factory.setReadTimeout(read_timeout);//单位为ms
factory.setConnectTimeout(connect_timeout);//单位为ms
factory.setOutputStreaming(false);
// InetSocketAddress socketAddress = new InetSocketAddress("192.168.124.31", 8888);

View File

@ -20,6 +20,10 @@ big_date:
census:
type: 应用资源,组件服务,基础设施,数据资源,知识库
applyType: 应用资源,业务组件,图层服务,开发组件,智能算法
# 全局RestTemplate配置
rest_template:
read_timeout: 30000
connect_timeout: 5000
# 海信网关
hisense:
gateway: