Burninghering's Blog
article thumbnail
Naver 지역 검색 API 사용하기
Spring 2022. 7. 18. 03:14

https://developers.naver.com/docs/serviceapi/search/local/local.md#%EC%A7%80%EC%97%AD 지역 - Search API 지역 NAVER Developers - 검색 API 지역 검색 개발가이드 검색 > 지역 네이버 지역 서비스에 등록된 각 지역별 업체 및 상호 검색 결과를 출력해주는 REST API입니다. 비로그인 오픈 API이므로 GET으로 호출 developers.naver.com https://developers.naver.com/apps/#/myapps/TNYycpp5NSwKwDC0xjpg/overview 애플리케이션 - NAVER Developers developers.naver.com 클라이언트 ID와 Client Secret을 할..

article thumbnail
Server to server - header
Spring 2022. 7. 16. 20:50

클라이언트에서 헤더를 넣어서 보내보자 package com.example.client.service; import com.example.client.dto.UserRequest; import com.example.client.dto.UserResponse; import org.apache.catalina.User; import org.springframework.http.MediaType; import org.springframework.http.RequestEntity; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; import org.springframework.web.clien..

article thumbnail
Server to server - POST
Spring 2022. 6. 27. 02:48

client의 RestTemplateService.java post 부분 넣기 package com.example.client.service; import com.example.client.dto.UserRequest; import com.example.client.dto.UserResponse; import org.apache.catalina.User; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; import org.springframework.web.client.RestTemplate; import org.springframework.web.util.UriComponentsBu..

article thumbnail
Server to server - GET
Spring 2022. 6. 26. 05:58

Client 서버 만들기 server.port=8080 package com.example.client.controller; import com.example.client.service.RestTemplateService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController @RequestM..

article thumbnail
Spring Boot - Interceptor
Spring 2022. 6. 20. 18:16

Filter는 Web application에 등록된다 package com.example.intercepter.intercepter; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; import org.springframework.web.method.HandlerMethod; import org.springframework.web.servlet.HandlerInterceptor; import org.springframework.web.servlet.resource.ResourceHttpRequestHandler; import javax.servlet.http.HttpServletRequest; import..

article thumbnail
Spring boot - Filter
Spring 2022. 6. 18. 05:31

처음으로 Lombok 사용해보기! @Data를 쓰면, Getter/Setter뿐만 아니라 equals/hashCode/toString까지 만들어준다 Lombok이 프로그램이 실행될때는 필요없다 컴파일됐을 때 이미 클래스파일에다 생성자/Getter/Setter 등이 만들어져있기 때문에 여태까지는 sout를 사용하여 시스템 로그를 남겨왔는데, @Slf4j 어노테이션을 사용하면 로그를 쉽게 남길 수 있다. package com.example.filter.controller; import com.example.filter.dto.User; import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.PostMapping; imp..

article thumbnail
Spring - DTO를 사용하는 이유
Spring 2022. 6. 16. 20:17

DTO란 무엇인가, VO와의 비교 오늘은 다음의 고민 때문에 글을 작성하게 되었다. DTO가 정확히 뭘 의미하는 거지? DTO를 꼭 써야하는 이유가 뭐지? DTO랑 VO를 많이 비교하던데, 뭐가 다른거지? DTO란 무엇인가 DTO(Data Transfer Object, kafcamus.tistory.com 위 블로그에서 자세하게 서술해주고 있다! VO와 DTO의 차이점에 대해서도 서술하고 있으니 참고하길.., 결론적으로 한번의 호출에 많은 데이터를 묶어 보내는 것이 효율적이기 때문이다. 책의 가격/저자/출판사 데이터를 다 따로 만들어 비즈니스 로직을 처리한다면 얼마나 비효율적이겠는가? 그러므로 요청에 대한 모든 데이터를 보관할 수 있는 데이터 전송 객체, DTO를 만들어 사용한다. Spring DTO의 ..

article thumbnail
Validation 모범 사례
Spring 2022. 6. 13. 23:01

Global하게 잡아주던 예외처리를 한 클래스에만 한정되어 지정해주게 함 package com.example.exception.advice; import com.example.exception.controller.ApiController; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.MethodArgumentNotValidException; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.an..