Spring+SpringMvc+Mybatis整合

本文档详细介绍了如何在一个Maven Web工程中整合Spring、SpringMVC和Mybatis,包括添加依赖、配置web.xml、设置spring-mvc.xml和spring-mybatis.xml等步骤。
摘要由CSDN通过智能技术生成

项目环境:spring-4.3.7 + mybatis-3.3.0 + maven3.5+jdk8

1.新建maven web 工程,并且添加java文件夹

2.添加pom文件依赖以及插件

<properties>

<project.build.sourceEncoding>utf-8</project.build.sourceEncoding>

</properties>

 

<!-- spring官方提供的依赖管理器,便于统一管理 -->

<dependencyManagement>

<dependencies>

<dependency>

<groupId>org.springframework</groupId>

<artifactId>spring-framework-bom</artifactId>

<version>4.3.7.RELEASE</version>

<type>pom</type>

<scope>import</scope>

</dependency>

</dependencies>

</dependencyManagement>

 

<dependencies>

<!-- 引入web工程所需的依赖 -->

<dependency>

<groupId>javax.servlet</groupId>

<artifactId>javax.servlet-api</artifactId>

<version>3.1.0</version>

<scope>provided</scope>

</dependency>

<dependency>

<groupId>javax.servlet.jsp</groupId>

<artifactId>jsp-api</artifactId>

<version>2.2</version>

<scope>provided</scope>

</dependency>

<!-- 添加JSTL标签库 -->

<dependency>

<groupId>javax.servlet</groupId>

<artifactId>jstl</artifactId>

<version>1.2</version>

</dependency>

<dependency>

<groupId>taglibs</groupId>

<artifactId>standard</artifactId>

<version>1.1.2</version>

</dependency>

 

<!-- 引入测试所需的依赖,使用spring4.3.x版本整合需要引入junit4.12及以上 -->

<dependency>

<groupId>junit</groupId>

<artifactId>junit</artifactId>

<version>4.12</version>

<scope>test</scope>

</dependency>

<dependency>

<groupId>org.springframework</groupId>

<artifactId>spring-test</artifactId>

</dependency>

 

<!-- 整合SpringMVC会自动引入其他所需的spring核心依赖 -->

<dependency>

<groupId>org.springframework</groupId>

<artifactId>spring-webmvc</artifactId>

</dependency>

 

<!-- 添加mybatis依赖 -->

<dependency>

<groupId>org.mybatis</groupId>

<artifactId>mybatis</artifactId>

<version>3.3.0</version>

</dependency>

<!-- 添加mybatis与sping整合依赖 -->

<dependency>

<groupId>org.springframework</groupId>

<artifactId>spring-orm</artifactId>

</dependency>

<dependency>

<groupId>org.mybatis</groupId>

<artifactId>mybatis-spring</artifactId>

<version>1.2.3</version>

</dependency>

 

<!-- 添加MySQL数据库驱动依赖包. -->

<dependency>

<grou

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值