67,513
社区成员
发帖
与我相关
我的任务
分享
一般在xml文件配置
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
<property name = "dataSource" ref="dataSource">
</bean>
@Inject
public JdbcSpitterRepository(JdbcOperations jdbcOperations){
this.jdbcOperations = jdbcOperations;
}没错的,构造器注入,把spring容器中的jdbcTemplate赋值给jdbcOperations 字段。。。。
一般使用jdbcTemplate直接在程序中
@Autowired
private JdbcTemplate jdbcTemplate; 就可以了