搭建Mybatis+Spring开发环境集成Mapper

搭建Mybatis+Spring开发环境集成Mapper

  1. 加入 Maven 依赖信息
<dependency>
    <groupId>tk.mybatis</groupId>
    <artifactId>mapper</artifactId>
    <version>4.0.0-beta3</version>
</dependency>
  1. 修改 Spring 配置
<!-- 整合通用 Mapper 所需要做的配置修改: -->
<!-- 原始全类名:org.mybatis.spring.mapper.MapperScannerConfigurer -->
<!-- 通用 Mapper 使用:tk.mybatis.spring.mapper.MapperScannerConfigurer -->
<bean class="tk.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.atguigu.mapper.mappers"/>
</bean>
  1. 第一个操作
/**
* 具 体 操 作 数 据 库 的 Mapper 接 口 , 需 要 继 承 通 用 Mapper 提 供 的 核 心 接 口 :
Mapper<Employee>
* 泛型类型就是实体类的类型
* @author Lenovo
*/
public interface EmployeeMapper extends Mapper<Employee> {
}

猜你喜欢

转载自blog.csdn.net/mrcool2012/article/details/105156573