Skip to content

Commit 2081521

Browse files
jhoellerunknown
authored and
unknown
committed
@Autowired and @value may be used as meta-annotations for custom injection annotations
1 parent 7fdb637 commit 2081521

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

spring-beans/src/main/java/org/springframework/beans/factory/annotation/Autowired.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
* @see Qualifier
6565
* @see Value
6666
*/
67-
@Target({ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.METHOD})
67+
@Target({ElementType.CONSTRUCTOR, ElementType.FIELD, ElementType.METHOD, ElementType.ANNOTATION_TYPE})
6868
@Retention(RetentionPolicy.RUNTIME)
6969
@Documented
7070
public @interface Autowired {

spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
import org.springframework.core.MethodParameter;
5656
import org.springframework.core.Ordered;
5757
import org.springframework.core.PriorityOrdered;
58+
import org.springframework.core.annotation.AnnotationUtils;
5859
import org.springframework.util.Assert;
5960
import org.springframework.util.ClassUtils;
6061
import org.springframework.util.ReflectionUtils;
@@ -372,7 +373,7 @@ private InjectionMetadata buildAutowiringMetadata(Class<?> clazz) {
372373

373374
private Annotation findAutowiredAnnotation(AccessibleObject ao) {
374375
for (Class<? extends Annotation> type : this.autowiredAnnotationTypes) {
375-
Annotation annotation = ao.getAnnotation(type);
376+
Annotation annotation = AnnotationUtils.getAnnotation(ao, type);
376377
if (annotation != null) {
377378
return annotation;
378379
}

spring-beans/src/main/java/org/springframework/beans/factory/annotation/Value.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
* @see org.springframework.beans.factory.config.BeanExpressionResolver
5050
* @see org.springframework.beans.factory.support.AutowireCandidateResolver#getSuggestedValue
5151
*/
52-
@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER})
52+
@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, ElementType.ANNOTATION_TYPE})
5353
@Retention(RetentionPolicy.RUNTIME)
5454
@Documented
5555
public @interface Value {

0 commit comments

Comments
 (0)