| | |
| | | import org.springframework.cloud.openfeign.EnableFeignClients; |
| | | import org.springframework.context.ApplicationContext; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; |
| | | import org.springframework.http.converter.StringHttpMessageConverter; |
| | | import org.springframework.scheduling.annotation.EnableAsync; |
| | | import org.springframework.scheduling.annotation.EnableScheduling; |
| | |
| | | StringHttpMessageConverter m = new StringHttpMessageConverter(Charset.forName("UTF-8")); |
| | | OutRestTemplate restTemplate = new RestTemplateBuilder().additionalMessageConverters(m).build(OutRestTemplate.class); |
| | | restTemplate.getInterceptors().add(java110RestTemplateInterceptor); |
| | | |
| | | //设置超时时间 |
| | | HttpComponentsClientHttpRequestFactory httpRequestFactory = new HttpComponentsClientHttpRequestFactory(); |
| | | httpRequestFactory.setConnectionRequestTimeout(5000); |
| | | httpRequestFactory.setConnectTimeout(5000); |
| | | httpRequestFactory.setReadTimeout(5000); |
| | | restTemplate.setRequestFactory(httpRequestFactory); |
| | | return restTemplate; |
| | | } |
| | | |