@Configuration
public?class?RestTemplateConfig?{
@Bean
public?RestTemplate?restTemplatMessageSdk()?{
HttpComponentsClientHttpRequestFactory?httpRequestFactory?=?new?HttpComponentsClientHttpRequestFactory();
httpRequestFactory.setConnectionRequestTimeout(1800000);
httpRequestFactory.setConnectTimeout(1800000);
httpRequestFactory.setReadTimeout(1800000);
RestTemplate?restTemplate?=?new?RestTemplate(httpRequestFactory);
StringHttpMessageConverter?t?=?new?StringHttpMessageConverter();
//设置为false就可以修改header中的accept-charset属性
t.setWriteAcceptCharset(false);
t.setDefaultCharset(StandardCharsets.UTF_8);
restTemplate.getMessageConverters().add(0,t);
return?restTemplate;
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…