diff --git a/spring-framework-reference/src/beans-annotation-config.xml b/spring-framework-reference/src/beans-annotation-config.xml index 6f4ececae7d..c8e5229725e 100644 --- a/spring-framework-reference/src/beans-annotation-config.xml +++ b/spring-framework-reference/src/beans-annotation-config.xml @@ -39,21 +39,18 @@ annotations is a common means of extending the Spring IoC container. For example, Spring 2.0 introduced the possibility of enforcing required properties with the @Required annotation. As of Spring 2.5, it is now possible to follow + >@Required annotation. Spring 2.5 made it possible to follow that same general approach to drive Spring's dependency injection. Essentially, the @Autowired annotation provides the same capabilities as described in but with more fine-grained control and - wider applicability. Spring 2.5 also adds support for JSR-250 annotations - such as @Resource, - @PostConstruct, and - @PreDestroy. Spring 3.0 adds support for + wider applicability. Spring 2.5 also added support for JSR-250 annotations + such as @PostConstruct, and + @PreDestroy. Spring 3.0 added support for JSR-330 (Dependency Injection for Java) annotations contained in the - javax.inject package such as @Inject, - @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. Annotation injection is performed + javax.inject package such as @Inject and + @Named. Details about those annotations can be found in the relevant section. 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 @@ -127,21 +124,13 @@
- <interfacename>@Autowired and @Inject</interfacename> + <interfacename>@Autowired</interfacename> As expected, you can apply the @Autowired annotation to "traditional" setter methods: - - JSR 330's @Inject annotation can be used in place of Spring's - @Autowired in the examples below. - @Inject does not have a required property - unlike Spring's @Autowired annotation - which has a required property to indicate if the - value being injected is optional. This behavior is enabled automatically - if you have the JSR 330 JAR on the classpath. - + public class SimpleMovieLister { @@ -155,6 +144,13 @@ // ... } + + JSR 330's @Inject annotation can be used in place of Spring's + @Autowired annotation in the examples below. See here for more details + + + You can also apply the annotation to methods with arbitrary names and/or multiple arguments: @@ -324,14 +320,6 @@ matches so that a specific bean is chosen for each argument. In the simplest case, this can be a plain descriptive value: - - JSR 330's @Qualifier annotation can - only be applied as a meta-annotation unlike Spring's @Qualifier which - takes a string property to discriminate among multiple injection - candidates and can be placed on annotations as well as types, fields, - methods, constructors, and parameters. - - public class MovieRecommender { @Autowired @@ -444,13 +432,6 @@ annotation and provide the @Qualifier annotation within your definition: - - You can use JSR 330's @Qualifier - annotation in the manner described below in place of - Spring's @Qualifier annotation. This - behavior is enabled automatically if you have the JSR 330 jar on the - classpath. - @Target({ElementType.FIELD, ElementType.PARAMETER}) @Retention(RetentionPolicy.RUNTIME)