From 3a9fc70f91f9c6329bab43733ddc7a6287959ba3 Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Sat, 7 Aug 2010 13:57:03 +0000 Subject: [PATCH] Add @Repository use to JdbcTemplate Best Practices (SPR-7339) --- spring-framework-reference/src/jdbc.xml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/spring-framework-reference/src/jdbc.xml b/spring-framework-reference/src/jdbc.xml index 9dae5cc1cf..8e3269cf3f 100644 --- a/spring-framework-reference/src/jdbc.xml +++ b/spring-framework-reference/src/jdbc.xml @@ -479,11 +479,14 @@ private static final class ActorMapper implements RowMapper<Actor> { An alternative to explicit configuration is to use component-scanning and annotation support for dependency injection. In - this case you annotate the setter method for the - DataSource with the - @Autowired annotation. - - public class JdbcCorporateEventDao implements CorporateEventDao { + this case you annotate the class with + @Repository (which makes it a candidate + for component-scanning) and annotate the + DataSource setter method with + @Autowired. + + @Repository +public class JdbcCorporateEventDao implements CorporateEventDao { private JdbcTemplate jdbcTemplate;