@SpringBootApplication
@RestController
@EnableWebMvc
public class DemoApplication {

private static String host = "xxxx";
private static String path = "xxxx";
private static String appcode = "xxx";

@Autowired
private RestTemplate restTemplate;

@Bean
public ClientHttpRequestFactory clientHttpRequestFactory() {
HttpComponentsClientHttpRequestFactory clientHttpRequestFactory = new HttpComponentsClientHttpRequestFactory();
clientHttpRequestFactory.setHttpClient(HttpClients.createDefault());
clientHttpRequestFactory.setConnectTimeout(10000);
clientHttpRequestFactory.setReadTimeout(10000);
clientHttpRequestFactory.setConnectionRequestTimeout(200);
return clientHttpRequestFactory;
}

@Bean
public RestTemplate restTemplate(ClientHttpRequestFactory clientHttpRequestFactory) {
RestTemplate restTemplate = new RestTemplateBuilder().requestFactory(clientHttpRequestFactory)
.additionalMessageConverters(new StringHttpMessageConverter(Charset.forName("UTF-8")))
.additionalInterceptors(new HttpHeaderInterceptor("Authorization", "APPCODE " + appcode)).build();
return restTemplate;
}

@GetMapping(value = "test", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public Object test() throws IOException {
Map<String, Object> params = new HashMap<>();
params.put("cityId", 2);
params.put("token", "677282c2f1b3d718152c4e25ed434bc4");
ObjectMapper objectMapper = new ObjectMapper();
String body = objectMapper.writer().writeValueAsString(params);
HttpEntity<String> formEntity = new HttpEntity<String>(body);
ResponseEntity<String> responseEntity = restTemplate.postForEntity(host + path, formEntity, String.class);
return responseEntity.getBody();
}

public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}