@Target(value=TYPE) @Retention(value=RUNTIME) @Documented @Component public @interface ControllerAdvice
Serves as a specialization of
@Component, allowing for
implementation classes to be autodetected through classpath scanning.
basePackages() or its alias
may be specified to define specific subsets of Controllers
to assist. When multiple selectors are applied, OR logic is applied -
meaning selected Controllers should match at least one selector.
The default behavior (i.e. if used without any selector),
@ControllerAdvice annotated class will
assist all known Controllers.
Note that those checks are done at runtime, so adding many attributes and using multiple strategies may have negative impacts (complexity, performance).
|Modifier and Type||Optional Element and Description|
Array of annotations.
Array of classes.
Type-safe alternative to
Array of base packages.
Alias for the
public abstract String basePackages
value() is an alias for this attribute.
Also consider using
basePackageClasses() as a type-safe
alternative to String-based package names.
public abstract Class<?> basePackageClasses
value()for specifying the packages to select Controllers to be assisted by the
Consider creating a special no-op marker class or interface in each package that serves no purpose other than being referenced by this attribute.
public abstract Class<?> assignableTypes
public abstract Class<? extends Annotation> annotations
Consider creating a special annotation or use a predefined one,