Bean的应用: SpringJdbcTemplate 实现


一、实现dao以及service的addUser

1. 建表
Spring(四)-SpringJdbcTemplate的实现
2. 创建User类、IUserDao接口、IUserDaoImpl实现类(具体里面的方法观看如下截图:)
  Spring(四)-SpringJdbcTemplate的实现
Spring(四)-SpringJdbcTemplate的实现
Spring(四)-SpringJdbcTemplate的实现
3. 编写applicationContext.xml配置文件
Spring(四)-SpringJdbcTemplate的实现
4. 编写db.properties文件
Spring(四)-SpringJdbcTemplate的实现
5. 在实现UserDaoImpl中的方法;
增:
Spring(四)-SpringJdbcTemplate的实现
6. 编写jdbcTemplate的测试方法
Spring(四)-SpringJdbcTemplate的实现
7. 结果:
Spring(四)-SpringJdbcTemplate的实现
那么剩下的几个方法同理我们一起编写一个service业务层
8.常见接口IUserService
Spring(四)-SpringJdbcTemplate的实现
9.实现IUserDaoImpl接口
Spring(四)-SpringJdbcTemplate的实现
10.配置文件中加入userService
Spring(四)-SpringJdbcTemplate的实现
11.编写测试类
Spring(四)-SpringJdbcTemplate的实现
12.结果:
Spring(四)-SpringJdbcTemplate的实现

二、剩下的继续编写删,改,查,

dao层
Spring(四)-SpringJdbcTemplate的实现
Spring(四)-SpringJdbcTemplate的实现
业务层
Spring(四)-SpringJdbcTemplate的实现
编写测试方法:
Spring(四)-SpringJdbcTemplate的实现
对应结果:
Spring(四)-SpringJdbcTemplate的实现
删除
Spring(四)-SpringJdbcTemplate的实现
结果:
Spring(四)-SpringJdbcTemplate的实现
查询方法:
Spring(四)-SpringJdbcTemplate的实现
总结这个过程虽然简单但是,很多的细节必须注意




相关文章: