目录
6)applicationContext-dao.xml 文件
7)applicationContext-service.xml 文件
8)applicationContext-trans.xml 文件
11)web.xml 文件,配置 SpringMVC 和 Spring 容器。
一、搭建分析
1)DAO 层
POJO 类,对应的映射文件 XxxMapper.xml 和 XxxMapper.java 接口类文件。
SqlMapConfig.xml : MyBatis 的核心配置文件。
beans-dao.xml 配置文件:主要是把 DAO 交给 Spring 管理。
数据源 dbcp / c3p0
会话工厂 sqlSessionFactory
扫描 mapper
2)Service 层
事务:beans-trans.xml 配置文件:将事务交给 Spring 管理。
beans-service.xml 配置文件:将 Service 交给 Spring 管理。
3)Controller 层
springmvc.xml 文件
注解扫描:@Controller、@RequestMapping
注解驱动:最新版本的处理器映射器和处理器适配器。
视图解析器:指定页面路径的前缀和后缀。
4)web.xml 文件
springMVC 前端控制器:DispatcherServlet
spring 的监听器
二.开始搭建
1)创建动态 web 工程,并且进行项目分包
2)导入 jar 包
jar 包整合下载:
https://download.csdn.net/download/weidong_y/10617848
3)在数据库中添加数据
user 表
items 表
4)通过逆向工程生成对应的文件
5)添加配置文件
6)applicationContext-dao.xml 文件
<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util.xsd">
<!-- 加载配置文件 -->
<context:property-pla