整合Mybatis与Spring框架
整合Mybatis与Spring框架步骤:
一、搭建项目环境
1、创建web工程,如图1-1所示
web工程 1-1
2、在lib文件夹导入所需jar包,如图2-1所示
导入jar包 2-1
3、在src/mian/resource下配置Spring XML文件以及mybatis.xml文件,和log4j.properties文件,如图3-1所示:
配置文件 3-1
area.xml文件用来配置sql语句;
application.xml文件中的配置如下:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:tx="http://www.springframewor