Deprecate convention-based @Component
stereotype names in favor of @AliasFor
#31093
Closed
2 tasks done
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
type: enhancement
A general enhancement
Milestone
Overview
Historically,
@Component
stereotype names were only configurable via implicit convention-based annotation attribute overrides of theString 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
@Service
should add@AliasFor
for@Component
[SPR-16066] #20615@ControllerAdvice
[SPR-16566] #21108@AliasFor
#28760@Component
stereotype names using@AliasFor
semantics #31089Deliverables
@Component(value)
are deprecated in favor of@AliasFor(annotation = Component.class, attribute = "value")
.@Component(value)
is detected, log a warning stating the reasons mentioned above.The text was updated successfully, but these errors were encountered: