http 프로토콜로 통신하는법
https://www.baeldung.com/spring-resttemplate-post-json
https://recordsoflife.tistory.com/360
public void reqThreadStart(String jsonData) { //8080 포트 서버임, 8081로 전송
logger.debug("받은 jsonData: " + jsonData);
RestTemplate rt = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
//MultiValueMap<String, String> parames = new LinkedMultiValueMap<>();
//parames.add("jsonData", jsonData);
HttpEntity<String> request = new HttpEntity<>(jsonData, headers);
//ResponseEntity response = rt.exchange("http://localhost:8081/test", HttpMethod.GET, request, String.class);
String response = rt.postForObject("http://localhost:8081/test", request, String.class);
ObjectMapper objectMapper = new ObjectMapper();
//json 데이터 전송
System.out.println(response);
}
@PostMapping("/test") //받는 8081 서버
public String 체크(@RequestBody String jsonData) {
System.out.println("들어왔나?");
System.out.println(jsonData);
return jsonData;
}
https://easybrother0103.tistory.com/103