-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Description
Overview
Although #20615 introduced the use of @AliasFor for @Component(value) in stereotype annotations (@Service, @Controller, @Repository, @Configuration, @RestController), the framework does not actually rely on @AliasFor support when looking up a component name via stereotype annotations. Rather, the framework has custom annotation parsing logic in AnnotationBeanNameGenerator#determineBeanNameFromAnnotation() which effectively ignores explicit annotation attribute overrides configured via @AliasFor.
Thus, although we can introduce the use of @AliasFor in @ControllerAdvice and @RestControllerAdvice to create aliases for @Component(value) (see #21108), those aliases will not be honored unless we revise the algorithm in AnnotationBeanNameGenerator.
Related Issues
- Stereotype annotations like
@Serviceshould add@AliasForfor@Component[SPR-16066] #20615 - Allow component name to be specified in
@ControllerAdvice[SPR-16566] #21108 - Deprecate convention-based
@Componentstereotype names in favor of@AliasFor#31093
Deliverables
- Revise
AnnotationBeanNameGenerator#determineBeanNameFromAnnotation()to look up@Componentstereotype names using@AliasForsemantics. - Update documentation for
@Componentto inform users that custom stereotypes can make use of@AliasForto create an alias for@Component(value).