RestTemplateConfig.java 667 B

1234567891011121314151617
  1. package com.github.jfcloud.common.config;
  2. import org.springframework.context.annotation.Bean;
  3. import org.springframework.context.annotation.Configuration;
  4. import org.springframework.http.client.SimpleClientHttpRequestFactory;
  5. import org.springframework.web.client.RestTemplate;
  6. @Configuration
  7. public class RestTemplateConfig {
  8. @Bean
  9. public RestTemplate restTemplate() {
  10. SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
  11. factory.setConnectTimeout(30000); // 连接超时 30秒
  12. factory.setReadTimeout(60000); // 读取超时 60秒 (AI推理可能较慢)
  13. return new RestTemplate(factory);
  14. }
  15. }