From a9386f5c79e1687adfe6d3d2c5971718c6b0c5cf Mon Sep 17 00:00:00 2001 From: Costin Leau Date: Tue, 9 Feb 2010 11:17:07 +0000 Subject: [PATCH] SPR-5246 + clarify order of annotation and XML injection --- .../annotation/AutowiredAnnotationBeanPostProcessor.java | 5 ++++- .../annotation/CommonAnnotationBeanPostProcessor.java | 3 +++ spring-framework-reference/src/beans.xml | 9 ++++++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/org.springframework.beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java b/org.springframework.beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java index 7853858693..52cf15866a 100644 --- a/org.springframework.beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java +++ b/org.springframework.beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java @@ -90,7 +90,10 @@ import org.springframework.util.ReflectionUtils; * by the "context:annotation-config" and "context:component-scan" XML tags. * Remove or turn off the default annotation configuration there if you intend * to specify a custom AutowiredAnnotationBeanPostProcessor bean definition. - * + *

NOTE: Annotation injection will be performed before XML injection; thus + * the latter configuration will override the former for properties wired through + * both approaches. + * * @author Juergen Hoeller * @author Mark Fisher * @since 2.5 diff --git a/org.springframework.context/src/main/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessor.java b/org.springframework.context/src/main/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessor.java index 1e4495d1af..d981c811a5 100644 --- a/org.springframework.context/src/main/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessor.java +++ b/org.springframework.context/src/main/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessor.java @@ -124,6 +124,9 @@ import org.springframework.util.StringUtils; * by the "context:annotation-config" and "context:component-scan" XML tags. * Remove or turn off the default annotation configuration there if you intend * to specify a custom CommonAnnotationBeanPostProcessor bean definition! + *

NOTE: Annotation injection will be performed before XML injection; thus + * the latter configuration will override the former for properties wired through + * both approaches. * * @author Juergen Hoeller * @since 2.5 diff --git a/spring-framework-reference/src/beans.xml b/spring-framework-reference/src/beans.xml index da2e2b19be..e9befff368 100644 --- a/spring-framework-reference/src/beans.xml +++ b/spring-framework-reference/src/beans.xml @@ -4438,7 +4438,14 @@ dataSource.url=jdbc:mysql:mydb @Qualifier, @Named, and @Provider if the JSR330 jar is present on the classpath. Use of these annotations also requires that certain BeanPostProcessors be registered - within the Spring container. As always, you can register them as + within the Spring container. + + Annotation injection is performed before XML injection, thus + the latter configuration will override the former for properties wired + through both approaches. + + + As always, you can register them as individual bean definitions, but they can also be implicitly registered by including the following tag in an XML-based Spring configuration (notice the inclusion of the context namespace):