| 
					
				 | 
			
			
				@@ -0,0 +1,39 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+package com.flyer.foster.config; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.context.annotation.Bean; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.context.annotation.Configuration; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.http.MediaType; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.http.client.ClientHttpRequestFactory; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.http.client.SimpleClientHttpRequestFactory; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.http.converter.StringHttpMessageConverter; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.web.client.RestTemplate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.nio.charset.StandardCharsets; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.Arrays; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ * RestTemplateConfig 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ * 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ * @author kelei 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ * @since 2022/5/13/11:57 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+@Configuration 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+public class RestTemplateConfig { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Bean 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public RestTemplate restTemplate(ClientHttpRequestFactory factory) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        RestTemplate restTemplate = new RestTemplate(factory); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        StringHttpMessageConverter stringConvert = new StringHttpMessageConverter(StandardCharsets.UTF_8); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        stringConvert.setSupportedMediaTypes(Arrays.asList(MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        restTemplate.getMessageConverters().add(stringConvert); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return new RestTemplate(factory); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Bean 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public ClientHttpRequestFactory simpleClientHttpRequestFactory() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 单位ms 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        factory.setReadTimeout(150000); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        factory.setConnectTimeout(150000); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return factory; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 |