feat: 添加RestTemplate配置类
This commit is contained in:
@@ -0,0 +1,28 @@
|
|||||||
|
package com.ruoyi.lsfx.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.SimpleClientHttpRequestFactory;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RestTemplate配置
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
public class RestTemplateConfig {
|
||||||
|
|
||||||
|
@Value("${lsfx.api.connection-timeout:30000}")
|
||||||
|
private int connectionTimeout;
|
||||||
|
|
||||||
|
@Value("${lsfx.api.read-timeout:60000}")
|
||||||
|
private int readTimeout;
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public RestTemplate restTemplate() {
|
||||||
|
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
|
||||||
|
factory.setConnectTimeout(connectionTimeout);
|
||||||
|
factory.setReadTimeout(readTimeout);
|
||||||
|
return new RestTemplate(factory);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user