restTemplate进行多服务间的方法的调用
1.创建restTemplate对象
RestTemplate restTemplate = new RestTemplate();
2.设置请求头信息
HttpHeaders httpHeaders=new HttpHeaders();
3.设置请求body
HttpEntity httpEntity = new HttpEntity<>(JSONObject.toJSON(Demo.addChannelParamDTO()), httpHeaders);
ResponseEntity response =restTemplate.exchange(http://localhost:8080+项目名+方法路径,HttpMethod.POST,httpEntity,String.class)
restTemplate实现接口间的服务调用
于 2022-08-16 09:32:06 首次发布