Update 28.2. Using JdbcTemplate.md

master
qibaoguang 2015-02-11 00:02:24 +08:00
parent 9441f9c531
commit afccecfd70
1 changed files with 20 additions and 0 deletions

View File

@ -0,0 +1,20 @@
### 28.2. 使用JdbcTemplate
Spring的JdbcTemplate和NamedParameterJdbcTemplate类是被自动配置的你可以在自己的beans中通过@Autowire直接注入它们。
```java
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
@Component
public class MyBean {
private final JdbcTemplate jdbcTemplate;
@Autowired
public MyBean(JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
}
// ...
}
```