Description
Overview
Historically, @Component
stereotype names were only configurable via implicit convention-based annotation attribute overrides of the String value()
attribute; however, Spring Framework 4.2 introduced support for explicit annotation attribute overrides via @AliasFor
. In addition, #20615 introduced the use of @AliasFor
for @Component(value)
in core stereotype annotations (@Service
, @Controller
, @Repository
, @Configuration
, @RestController
), but the framework did not actually rely on @AliasFor
support when looking up a component name via stereotype annotations until #31089.
Since explicit overrides are favorable to implicit overrides, and since the support for convention-based overrides increases the complexity of Spring's annotation search algorithms, we will deprecate convention-based overrides for @Component
stereotype names in 6.1.
Related Issues
- Stereotype annotations like
@Service
should add@AliasFor
for@Component
[SPR-16066] #20615 - Allow component name to be specified in
@ControllerAdvice
[SPR-16566] #21108 - Deprecate convention-based annotation attribute overrides in favor of
@AliasFor
#28760 - Look up
@Component
stereotype names using@AliasFor
semantics #31089
Deliverables
- Update Javadoc and reference documentation to inform users that convention-based overrides for
@Component(value)
are deprecated in favor of@AliasFor(annotation = Component.class, attribute = "value")
. - Whenever a convention-based override for
@Component(value)
is detected, log a warning stating the reasons mentioned above.