|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2018 the original author or authors. |
| 2 | + * Copyright 2002-2019 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
23 | 23 | import java.lang.annotation.Target;
|
24 | 24 |
|
25 | 25 | /**
|
26 |
| - * Marks a constructor, field, setter method or config method as to be autowired by |
| 26 | + * Marks a constructor, field, setter method, or config method as to be autowired by |
27 | 27 | * Spring's dependency injection facilities. This is an alternative to the JSR-330
|
28 | 28 | * {@link javax.inject.Inject} annotation, adding required-vs-optional semantics.
|
29 | 29 | *
|
30 |
| - * <p>Only one constructor (at max) of any given bean class may declare this annotation |
31 |
| - * with the 'required' parameter set to {@code true}, indicating <i>the</i> constructor |
32 |
| - * to autowire when used as a Spring bean. If multiple <i>non-required</i> constructors |
33 |
| - * declare the annotation, they will be considered as candidates for autowiring. |
34 |
| - * The constructor with the greatest number of dependencies that can be satisfied by |
35 |
| - * matching beans in the Spring container will be chosen. If none of the candidates |
36 |
| - * can be satisfied, then a primary/default constructor (if present) will be used. |
37 |
| - * If a class only declares a single constructor to begin with, it will always be used, |
38 |
| - * even if not annotated. An annotated constructor does not have to be public. |
| 30 | + * <p>Only one constructor of any given bean class may declare this annotation with |
| 31 | + * the 'required' attribute set to {@code true}, indicating <i>the</i> constructor |
| 32 | + * to autowire when used as a Spring bean. Furthermore, if the 'required' attribute |
| 33 | + * is set to {@code true}, only a single constructor may be annotated with |
| 34 | + * {@code @Autowired}. If multiple <i>non-required</i> constructors declare the |
| 35 | + * annotation, they will be considered as candidates for autowiring. The constructor |
| 36 | + * with the greatest number of dependencies that can be satisfied by matching beans |
| 37 | + * in the Spring container will be chosen. If none of the candidates can be satisfied, |
| 38 | + * then a primary/default constructor (if present) will be used. If a class only |
| 39 | + * declares a single constructor to begin with, it will always be used, even if not |
| 40 | + * annotated. An annotated constructor does not have to be public. |
39 | 41 | *
|
40 | 42 | * <p>Fields are injected right after construction of a bean, before any config methods
|
41 | 43 | * are invoked. Such a config field does not have to be public.
|
|
45 | 47 | * Bean property setter methods are effectively just a special case of such a general
|
46 | 48 | * config method. Such config methods do not have to be public.
|
47 | 49 | *
|
48 |
| - * <p>In the case of a multi-arg constructor or method, the 'required' parameter is |
| 50 | + * <p>In the case of a multi-arg constructor or method, the 'required' attribute is |
49 | 51 | * applicable to all arguments. Individual parameters may be declared as Java-8-style
|
50 | 52 | * {@link java.util.Optional} or, as of Spring Framework 5.0, also as {@code @Nullable}
|
51 | 53 | * or a not-null parameter type in Kotlin, overriding the base required semantics.
|
|
0 commit comments