SSM整合

SSM整合

Spring–SpringMVC–MyBatis

第1步. Spring – MyBatis
真正需要整合:将MyBatis的 SqlSessionFactory 交给Spring管理

第2步. Spring – SpringMVC
就是将Spring – SpringMVC各自配置一遍

SM整合步骤

1.jar包
在这里插入图片描述
2.类-----表

Student类—student表
在这里插入图片描述

3.MyBatis的配置文件conf.xml(数据源、Mapper.xml映射文件路径)----可省略,将该文件中的配置全部交由Spring管理。

spring配置文件: applicationContext.xml

4.通过Mapper.xml将 类和表 建立映射关系

5.之前使用MyBatis:conf.xml----->SqlSessionFactory
现在整合的时候,需要通过Spring管理SqlSessionFactory

配置spring配置文件(applicationContext.xml) (Web项目):
web.xml:(web中引入Spring)
在这里插入图片描述

6.使用Spring整合MyBatis:核心是 将MyBatis的SqlSessionFactory交给Spring管理
![在这里插入图片描述](https://img-
在这里插入图片描述
上面basePackage所在的property的作用:
将org.lanqiao.mapper包中,所有的接口 产生与之对应的 动态代理对象(对象名就是首字母小写的接口名):studentMapper.queryAllStudent();

SS整合

7.继续整合SpringMVC:将Springmvc加入项目即可
a.加入SpringMVC所需的jar包
spring-webmvc.jar

b.配置SpringMVC(给项目加入SpringMVC支持)
web.xml: dispatcherServlet

c.编写SpringMVC配置文件
applicationContext-controller.xml:视图解析器、基础配置

d.示例

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值