思路:
SqlsessionFactory -> Sqlsession -> StudentMapper -> CRUD
- 导入jar
- 准备测试数据(类-表)
如:Student(stuno, name, age) - 创建studentMapper.xml并进行配置
- MyBatis的配置文件
- 编写StudentDaoImpl
- 创建db.properties配置文件
- 在spring的配置文件引入db.properties
- 之前在MyBatis中配置数据库,现在在spring中配置
- 在springIOC中创建mybatis的核心类sqlSessionFactoryBean,并将mybatis的配置文件加载到spring
- IOC中创建StudentMapper(之前的StudentDao)和StudentService,注意StudentMapper的创建