Browse Source

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
pull/1/head
Chris Beams 16 years ago
parent
commit
e1dfe5ca69
  1. 13
      spring-framework-reference/src/jdbc.xml

13
spring-framework-reference/src/jdbc.xml

@ -479,11 +479,14 @@ private static final class ActorMapper implements RowMapper<Actor> {
<para>An alternative to explicit configuration is to use <para>An alternative to explicit configuration is to use
component-scanning and annotation support for dependency injection. In component-scanning and annotation support for dependency injection. In
this case you annotate the setter method for the this case you annotate the class with
<classname>DataSource</classname> with the <interfacename>@Repository</interfacename> (which makes it a candidate
<interfacename>@Autowired</interfacename> annotation.<!--Re preceding sentence, I don't see @Autowired in next two examples. TR: OK AS IS. Made it *bold*--></para> for component-scanning) and annotate the
<classname>DataSource</classname> setter method with
<para><programlisting language="java">public class JdbcCorporateEventDao implements CorporateEventDao { <interfacename>@Autowired</interfacename>.<!--Re preceding sentence, I don't see @Autowired in next two examples. TR: OK AS IS. Made it *bold*--></para>
<para><programlisting language="java"><emphasis role="bold">@Repository</emphasis>
public class JdbcCorporateEventDao implements CorporateEventDao {
private JdbcTemplate jdbcTemplate; private JdbcTemplate jdbcTemplate;

Loading…
Cancel
Save