exception-handing-spring-boot learning validation and exception handling in spring boot application
There are two ways to handle exceptions in a spring boot application:
-
Creating a Base Controller, which all the other RestControllers will extend. The base controller contains methods annotated with @ExceptionHandler which handles exceptions
-
The best way is to create a Seperate Class annotated with @RestControllerAdvice or @ControllerAdvice which contains methods annotated with @ExceptionHandler which handles exceptions.