RestTemplate restTemplate = new RestTemplate();
HashMap<String, String> requestMap = new HashMap<>();
requestMap.put("test", "aaa");//参数
String url = "http://10.XX.XX.XX:8001/app-service";//请求地址
HttpHeaders headers = new HttpHeaders(); // http请求头
// headers.setContentType(MediaType.APPLICATION_JSON); // 请求头设置属性
HttpEntity<Map<String, String>> requestEntity = new HttpEntity<>(requestMap, headers);
//post请求方式
String forObject = restTemplate.postForObject(url, requestEntity, String.class);
//get请求方式
//url:请求路径路径中可以添加参数
//String.class:标识返回数据类型
restTemplate.getForEntity(url, String.class);
System.out.println(forObject);