Add @Repository use to JdbcTemplate Best Practices (SPR-7339)

master
Chris Beams 14 years ago
parent 30b0e5e250
commit 3a9fc70f91
  1. 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
component-scanning and annotation support for dependency injection. In
this case you annotate the setter method for the
<classname>DataSource</classname> with the
<interfacename>@Autowired</interfacename> annotation.<!--Re preceding sentence, I don't see @Autowired in next two examples. TR: OK AS IS. Made it *bold*--></para>
<para><programlisting language="java">public class JdbcCorporateEventDao implements CorporateEventDao {
this case you annotate the class with
<interfacename>@Repository</interfacename> (which makes it a candidate
for component-scanning) and annotate the
<classname>DataSource</classname> setter method with
<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;

Loading…
Cancel
Save