Spring

Spring

RestTemplate, WebClient

현재 개발하고 있는 코드에 RestTemplate을 사용하고 있는 부분이 있다. 찾아보니 WebClient를 쓰는 것을 권하는 것 같은데, 프로젝트의 스프링 버전이 4.3.3이라 사용할 수 없지만, 미리 공부해두면 좋을 거 같아서 기록을 남기려고 한다. RestTemplate HttpAccessor > InterceptingHttpAccessor 아래에 있는 Spring Framework의 클래스 Client의 HTTP 요청 동기화, 기본 HTTP Client 라이브러리를 통한 템플릿 메서드 (JDK의 HttpURLConnection 같은) HTTP에서 기본적으로 제공하는 메소드를 제공하고, 일반화 된 exchange와 execute메서드가 추가되어있다. 참고로, 스프링 5.0 부터는 유지 보수 정도만 ..

Spring

@RequestParam, @PathVariable

Query Parameter, URI Path로 구분 @RequestParam과 @PathVariable은 모두 request URI를 처리할 때 사용한다. QueryParameter, URI Path로 구분할 수 있는데 QueryParameter인 경우에는 @RequestParams를 사용하고, URI Path인 경우에는 @PathVariable를 사용한다. @GetMapping("/foos/{id}") @ResponseBody public String getFooById(@PathVariable String id) { return "ID: " + id; } http://localhost:8080/spring-mvc-basics/foos/abc --- ID: abc @GetMapping("/foos")..

Spring

HttpClient, HttpEntity

HttpRequest를 사용하려 했는데, 서비스 D의 경우 java 1.8을 사용하고 있어서 HttpRequest 적용이 안 되었다... ㅎ;; 결국 HttpEntity와 ResponseEntity를 이용하여 작업을 진행했는데, 이 과정에서 HttpClient, HttpRequest, HttpResponse, HttpEntity, ResponseEntity에 대하여 공부한 기록을 남겨보려고 한다. HttpClient, HttpRequest, HttpResponse HTTP Client는 Java 11에서 추가되었고, HTTP request를 이용하는데 사용한다. HTTP/1.1과 HTTP/2, 동기식 비동기식 프로그래밍을 지원하고, request와 response bodies를 reactive-strea..

mean-ji
'Spring' 카테고리의 글 목록 (2 Page)