Spring Boot: @ControllerAdvice/@RestControllerAdvice로 예외처리하기
·
Spring/Spring 기초 지식
@ControllerAdvice와 @RestControllerAdvice에 대해 자세히 알아보자 📌 서론 프로그래밍에서 예외 처리는 매우 중요한 부분이며, Spring Boot에서는 @ControllerAdvice와 @RestControllerAdvice를 통해 이를 효율적으로 수행할 수 있다. 이 어노테이션들은 코드의 재사용성과 유지 보수성을 높여, 복잡한 비즈니스 로직에서도 예외 상황을 안정적으로 관리할 수 있게 해준다. 1. @ControllerAdvice이해 @ControllerAdvice란? @ControllerAdvice는 Spring 3.2에서 도입된 어노테이션으로, 모든 @Controller 클래스가 공유하는 공통 로직을 정의할 때 사용한다. 주로 예외 처리와 바인딩 설정, 모델 객체 등에..