일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
- 인프런
- 자바
- kotlin
- springdatajpa
- AOP
- java
- 스프링 핵심 기능
- Servlet
- 스프링 핵심 원리
- http
- QueryDSL
- jpa
- Proxy
- Exception
- Greedy
- Thymeleaf
- SpringBoot
- 알고리즘
- JPQL
- 백준
- 그리디
- Spring Boot
- db
- spring
- JDBC
- Android
- 스프링
- 김영한
- transaction
- pointcut
- Today
- Total
목록@ControllerAdvice (2)
개발자되기 프로젝트
[API예외] @ControllerAdvice @ExceptionHandler 를 사용해서 예외를 깔끔하게 처리할 수 있게 되었지만, 정상 코드와 예외 처리 코드가 하나의 컨트롤러에 섞여 있다. @ControllerAdvice 또는 @RestControllerAdvice 를 사용하면.. bsh-developer.tistory.com @ControllerAdvice는 Controller에서 발생하는 Exception을 어떻게 처리할지 따로 분류해서 관리할 수 있도록 도와줌. 말 그대로 Controller에 대한 Advice이다. 아래와 같이 IndexOutOfBounds Exception이 무조건 발생하는 Controller가 있다고 해보자. @RestController @RequestMapping("/a..
@ExceptionHandler 를 사용해서 예외를 깔끔하게 처리할 수 있게 되었지만, 정상 코드와 예외 처리 코드가 하나의 컨트롤러에 섞여 있다. @ControllerAdvice 또는 @RestControllerAdvice 를 사용하면 둘을 분리할 수 있다. 1.@ControllerAdvice Controller에 있던 오류 처리 코드를 분리해 내자. @RestControllerAdvice를 적용한 ExControllerAdvice 클래스를 생성하여 코드를 여기로 옮겨놓자. 그러면 여러 controller에서 발생한 Exception을 ControllerAdvice에서 처리해줌. @Slf4j @RestControllerAdvice public class ExControllerAdvice { @Respo..