Skip to content

Misleading description in Autowired javadoc [SPR-17299] #21832

Closed
@spring-projects-issues

Description

@spring-projects-issues

rupertw opened SPR-17299 and commented

Comments on applying the annotation Autowired to constructor are error,

* <p>Only one constructor (at max) of any given bean class may carry this annotation,
* indicating the constructor to autowire when used as a Spring bean. Such a
* constructor does not have to be public.

we can refer to the javadoc of class AutowiredAnnotationBeanPostProcessor for correct description.

* <p>Only one constructor (at max) of any given bean class may carry this
* annotation with the 'required' parameter set to {@code true},
* indicating <i>the</i> constructor to autowire when used as a Spring bean.
* If multiple <i>non-required</i> constructors carry the annotation, they
* will be considered as candidates for autowiring. The constructor with
* the greatest number of dependencies that can be satisfied by matching
* beans in the Spring container will be chosen. If none of the candidates
* can be satisfied, then a default constructor (if present) will be used.
* An annotated constructor does not have to be public.

Affects: 5.1 GA

Referenced from: pull request #1966

Backported to: 5.0.10, 4.3.20

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)status: backportedAn issue that has been backported to maintenance branchestype: documentationA documentation task

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions