This commit is contained in:
2026-04-17 10:32:57 +08:00
parent 572ad1205f
commit 17c52c978c
691 changed files with 72342 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
package com.maibu.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;
@Configuration
public class RestTemplateConfig {
@Bean
public RestTemplate restTemplate() {
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
factory.setConnectTimeout(5000); // 连接超时 5 秒
factory.setReadTimeout(5000); // 读取超时 5 秒
RestTemplate restTemplate = new RestTemplate(factory);
// // 只保留JSON转换器,确保只处理JSON格式的数据
// List<HttpMessageConverter<?>> converters = new ArrayList<>();
// converters.add(new MappingJackson2HttpMessageConverter());
// restTemplate.setMessageConverters(converters);
return restTemplate;
}
}