resttemplate 由于框架原因自带了转xml方式,不改变框架底层情况下,修复为返回json格式
RestTemplate httpClientTemplate = new RestTemplate(); List<HttpMessageConverter<?>> converters = httpClientTemplate.getMessageConverters(); List<HttpMessageConverter<?>> convertersValid = new ArrayList<HttpMessageConverter<?>>(); for (HttpMessageConverter<?> converter : converters) { if (converter instanceof MappingJackson2HttpMessageConverter || converter instanceof MappingJackson2XmlHttpMessageConverter) continue; convertersValid.add(converter); } convertersValid.add(new FastJsonHttpMessageConverter()); httpClientTemplate.setMessageConverters(convertersValid);