Allow component name to be specified in @[Rest]ControllerAdvice

This commit builds on the recently added support for using @AliasFor to
override the `value` attribute in `@Component, and allows a custom
component name to be specified in both @ControllerAdvice and
@RestControllerAdvice via new `name` attributes.

See gh-31089
Closes gh-21108
This commit is contained in:
Sam Brannen
2023-08-27 17:38:51 +02:00
parent e239753a1b
commit 4e2d9252e5
7 changed files with 117 additions and 4 deletions

View File

@@ -675,7 +675,7 @@ As of Spring Framework 6.1, the name of the annotation attribute that is used to
the bean name is no longer required to be `value`. Custom stereotype annotations can
declare an attribute with a different name (such as `name`) and annotate that attribute
with `@AliasFor(annotation = Component.class, attribute = "value")`. See the source code
declaration of `Repository#value()` for a concrete example.
declaration of `Repository#value()` and `ControllerAdvice#name()` for concrete examples.
====
If such an annotation contains no name `value` or for any other detected component