From e1dfe5ca692b2ff79313ea295ae5b8991c3ac06c 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) git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@3529 50f2f4bb-b051-0410-bef5-90022cba6387 --- 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 9dae5cc1cf1..8e3269cf3fe 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;