This article gives a quick summary of how to do autowiring with Spring 2.5 using annotations. We cover the data and services tiers here, but not the web tier. For information on web-tier configuration, please see my article Annotation-Based MVC in Spring 2.5.
To set the proper context, our goal is to get rid of manual namings and wirings in the configuration files, and the basic strategy is convention-over-configuration: name the various dependencies according to the property names so that Spring can figure out how to autowire your app.
<aside>Incidentally, I take it to be a separate and interesting
discussion as to whether autowiring is something that should be done in the first
place. One might reasonably argue that wiring is a configuration issue, and that
adding annotations everywhere amounts to distributing the configuration across the
various classes, thereby violating the principle of separation of concerns. Not to
mention the fact that we don't normally want to have to rebuild the app to make a
config change. I can see that in some cases it makes sense to separate concerns
(for example, I think modeling and persistence should generally be kept separate)
and in other cases it doesn't (for example, code documentation should not be separated
out). Anyway I won't argue here whether autowiring is good (I do think it is, but
I won't argue that); I'll just explain how to do it.</aside>
Here I assume that you're using Spring MVC and Hibernate. I'm also assuming that you already have separate beans configuration files for the web, service, and data access tiers, that they're currently not autowired (i.e. you want to migrate from a manual wiring to an autowired configuration). Nothing essential hinges upon these assumptions—they just reflect my own configuration—and the instructions should be useful even if your configuration is somewhat different.
Here we go.
Comments currently suppressed due to excessive spam. I'll reinstate them later, this time with approvals turned on. :-)