Skip to content

Latest commit

 

History

History
35 lines (24 loc) · 1.85 KB

File metadata and controls

35 lines (24 loc) · 1.85 KB

https://loizenai.com/restcontrolleradvice-springboot-example/

@RestControllerAdvice Example SpringBoot

@RestControllerAdvice Example SpringBoot

Tutorial: “@RestControllerAdvice Example SpringBoot – Error Handling for REST with Spring”.

In the article, I introduce about @RestControllerAdvice annotation of SpringBoot to handle RestAPI exception with a Github running sourcecode and details explanation example steps.

  • Technologies we use in the article: – Java 1.8 – Maven – Spring Boot

Annotation Type @RestControllerAdvice

@RestControllerAdvice is a new feature of Spring Framework 4.3, an annotation with combined @ControllerAdvice + @ResponseBody. So @RestControllerAdvice can help us to handle Exception with RestfulApi by a cross-cutting concern solution: @ExceptionHandler.

@Target(value=TYPE) @Retention(value=RUNTIME) @Documented @ControllerAdvice @ResponseBody public @interface RestControllerAdvice

@RestControllerAdvice is processed if an appropriate HandlerMapping-HandlerAdapter pair is configured such as the RequestMappingHandlerMapping-RequestMappingHandlerAdapter pair which are the default in the MVC Java config and the MVC namespace.

Related post