Annotation Type ControllerAdvice


@Retention(CLASS) @Target(TYPE) public @interface ControllerAdvice

A bean whose ExceptionHandler methods apply to every controller.

Several are asked in Order order, the unordered ones last by bean name, and only after the failing controller's own handlers declined. The build writes the dispatch to each handler as code; nothing is found by reflection.

  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Limits the advice to controllers in these packages and their subpackages; empty for every controller.
    The bean name; empty for the default.
  • Element Details

    • value

      String value
      The bean name; empty for the default.
      Default:
      ""
    • basePackages

      String[] basePackages
      Limits the advice to controllers in these packages and their subpackages; empty for every controller.
      Default:
      {}