Files
klp-oa/klp-common/src/main/java/com/klp/common/config/RestTemplateConfig.java

24 lines
732 B
Java
Raw Normal View History

2025-08-02 16:40:16 +08:00
package com.klp.common.config;
2025-08-02 13:12:56 +08:00
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;
/**
* RestTemplate配置类
*/
@Configuration
public class RestTemplateConfig {
2025-08-02 16:40:16 +08:00
2025-08-02 13:12:56 +08:00
@Bean
public RestTemplate restTemplate() {
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
factory.setConnectTimeout(30000); // 30秒连接超时
factory.setReadTimeout(60000); // 60秒读取超时
2025-08-02 16:40:16 +08:00
2025-08-02 13:12:56 +08:00
return new RestTemplate(factory);
}
2025-08-02 16:40:16 +08:00
}