1、需求
使用springmvc和mybatis完成商品列表查询
2、整合思路
springmvc+mybatis的系统架构
第一步:整合dao层
mybatis和spring整合,使用spring管理mapper接口
使用mapper的扫描器自动扫描mapper接口在spring中进行注册
第二步:整合service层
通过spring管理service接口
通过配置方式将service接口配置在spring配置文件中
第三步:整合springmvc
由于springmvc是spring的模块,不需要整合
3、准备环境
mysql数据库
相关jar包
工程目录:
4、整合dao
4.1 classpath*:mybatis/sqlMapConfig.xml文件
4.2 classpath*:spring/applicationContext-dao.xml
加上<context:component-scan base-package="com.ssm.service"/>自动扫描
4.3 classpath*:mapper/*.xml(mapper.xml文件)
· 4.4 po文件