mirror of
https://github.com/spring-projects/spring-framework
synced 2026-06-08 17:33:33 +00:00
ff104b6de0
Although gh-20615 introduced the use of @AliasFor for @Component(value) in the built-in stereotype annotations (@Service, @Controller, @Repository, @Configuration, and @RestController), prior to this commit the framework did not actually rely on @AliasFor support when looking up a component name via stereotype annotations. Rather, the framework had custom annotation parsing logic in AnnotationBeanNameGenerator#determineBeanNameFromAnnotation() which effectively ignored explicit annotation attribute overrides configured via @AliasFor. This commit revises AnnotationBeanNameGenerator#determineBeanNameFromAnnotation() so that it first looks up @Component stereotype names using @AliasFor semantics before falling back to the "convention-based" component name lookup strategy. Consequently, the name of the annotation attribute that is used to specify the bean name is no longer required to be `value`, and custom stereotype annotations can now declare an attribute with a different name (such as `name`) and annotate that attribute with `@AliasFor(annotation = Component.class, attribute = "value")`. Closes gh-31089