博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
SSM 整合
阅读量:7265 次
发布时间:2019-06-29

本文共 1051 字,大约阅读时间需要 3 分钟。

1. 导入jar包

  • SpringMVC 所需jar包;
  • MyBatis 所需jar包 mybatis-3.4.1 和数据库驱动jar包;
  • MyBatis 与 Spring 整合需要适配包: mybatis-spring-1.3.1

2. 配置文件

2.1 MyBatis 配置文件

  • MyBatis 全局配置文件: mybatis-config.xml;
  • 数据库配置文件: dbconfig.properties;
  • 对应接口的映射文件: xxxMapper.xml;

2.2 Spring 配置文件

  • 在 web.xml 中配置Spring核心监听器;
  • 在类路径下,创建 applicationContext.xml;

2.3 SpringMVC 配置文件

  • 在 web.xml 中配置 DispatcherServlet;
  • 在 WEB-INF 目录下创建 springDispatcherServlet-servlet.xml;
// applicationContext.xml
// EmployeeService.java public interface EmployeeMapper{ @Autowired private EmployeeMapper employeeMapper; @Autowired private SqlSession sqlSession; public List
getEmps(){ // 创建可以执行批量操作的代理对象 EmployeeMapper mapper = sqlSession.getMapper(EmployeeMapper.class); }

参考资料

转载于:https://www.cnblogs.com/linkworld/p/7797587.html

你可能感兴趣的文章
【转载】play framework 2.0 实战(4)- spring
查看>>
Java基础-深克隆与浅克隆的区别
查看>>
腾讯云数据盘挂载
查看>>
apache网站访问缓慢的处理记录
查看>>
curl 命令示例:
查看>>
使用wget从oracle下载jdk
查看>>
Struts2类型转换
查看>>
Unix环境高级编程笔记 :13、守护进程
查看>>
计算线段或直线与线段的交点
查看>>
让html select支持readonly属性
查看>>
编译安装 tokudb-xtrabackup 以支持tokudb的热备份
查看>>
解决“configure: line 2747: -g: command not found”
查看>>
linux下acl应用详解
查看>>
2-1 Windows软件 --- Cygwin的安装与简单使用
查看>>
Centos下Yum安装PHP5.5,5.6,7.0
查看>>
安卓手机 root及siri
查看>>
CentOS 6.3 编译安装HAproxy 1.4.22+keepalived1.2.7
查看>>
SANS:2014年安全分析与安全智能调研报告
查看>>
SpringMVC事务失效的解决方法
查看>>
html/css,与你同行的第30天。
查看>>