controlleradvice

    Spring Boot로 구현된 컨트롤러에서의 예외를 @RestControllerAdvice로 처리하기.

    기존에 진행하는 프로젝트에서는 Spring Boot로 REST API를 구현하면서 Service들에서 발생하는 여러 예외를 Controller의 메서드들에서 try/catch 문을 만들어 처리해 줬습니다이렇게 만들어두니 Controller는 복잡해지고 중복되는 코드들이 생겼으며,예외가 발생될 때마다 해당 예외에 대한 자세한 메시지를 작성해주어야 해서 관리가 어려웠습니다.이렇게 예외에 따른 처리를 Spring Boot에서 @RestControllerAdvice를 활용해 처리해 주는 방법을 정리해보고자 합니다! 기존 코드@RestController@RequestMapping("/api/v1/posts")@RequiredArgsConstructorpublic class PostController { pr..