Annotations simplify matters immensely when it comes to developing Java applications, in this post by Juergen Hoeller he describes a series of annotations that are supported in Spring's 2.5 version and how they benefit those working in and around Java EE 5 design paradigms.
Today I'd like to take a different focus, namely on the wide-ranging set of dependency injection annotations supported by Spring. The following list includes the key annotations that can be used within Spring 2.5 beans:
Identifies bean property setters that must be called (as opposed to optional setters). Supported since Spring 2.0.
Spring 2.5's central injection annotation, applying to constructors, config methods and fields. Performs injection of components by type, with supporting for "qualifier" annotations that narrow the potential set of candidates in case of multiple matches.
JSR-250's common annotation for what Spring calls "init methods".
JSR-250's common annotation for what Spring calls "destroy methods".
JSR-250's common annotation for injecting an external component by name. A "resource" in JSR-250 terminology really refers to a middleware component such as a DataSource.
@Resource-like, for JAX-WS service lookups, injecting a JAX-WS port proxy.
@Resource-like, for EJB Session Bean lookups, injecting an EJB component reference.
injecting a JPA EntityManagerFactory by persistence unit name. Supported since Spring 2.0.
injecting a JPA EntityManager by persistence unit name. Supported since Spring 2.0.
This set of annotations encompasses all of Java EE 5's common annotations, which means that you may use the same common annotations in e.g. Servlet 2.5 servlets, JSF 1.2 managed beans and Spring managed beans. In other words, if you have some standard JSF 1.2 managed beans with annotation usage, you can take them as-is and move their definitions from faces-config to a Spring application context, without any change in the bean classes! This was an important design goal: Spring 2.5 may serve as straightforward replacement of the standard JSF 1.2 managed bean facility, simply through choosing SpringBeanFacesELResolver as your custom JSF ELResolver.
Read Juergen Hoeller's complete post: http://blog.springsource.com/main/2008/01/28/spring-25s-comprehensive-annotation-support/