1.MyBatis配置文件(mybatis-config)

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<mappers></mappers>
</configuration>

2.Spring配置sqlSessionFactory

<bean id="sqlSessionFactory"
class="org.mybatis.spring.SqlSessionFactoryBean"
p:dataSource-ref="dataSource"
p:configLocation="classpath:conf/mybatis-config.xml"
p:mapperLocations="classpath:com/**/dao/sql/*xml"/>

configLocation:MyBatis配置文件路径;

SqlSessionFactoryBean提供了mapperLocations属性,支持扫描式加载SQL映射文件;

3.Spring配置MapperScannerConfigurer

<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"
p:basePackage="com.dogstore.dao"/>

MapperScannerConfigurer将扫描basePackage所指定的报下所有接口类,如果他们在SQL映射文件中定义过,则将他们动态定义为一个Spring Bean。这样,我们就可以在Service直接注入映射接口的Bean了。

Spring配置MyBatis的更多相关文章

  1. spring配置mybatis的sqlsessionfactory

    <!--读入配置文件 --> <bean id="propertyConfigurer" class="org.springframework.bean ...

  2. Spring+SpringMvc+Mybatis框架集成搭建教程二(依赖配置及框架整合)

    依赖导入以及框架整合 (1).打开项目的pom.xml文件,声明依赖 <project xmlns="http://maven.apache.org/POM/4.0.0" x ...

  3. MyBatis学习(一)、MyBatis简介与配置MyBatis+Spring+MySql

    一.MyBatis简介与配置MyBatis+Spring+MySql 1.1MyBatis简介 MyBatis 是一个可以自定义SQL.存储过程和高级映射的持久层框架.MyBatis 摒除了大部分的J ...

  4. Spring+springmvc+Mybatis整合案例 xml配置版(myeclipse)详细版

    Spring+springmvc+Mybatis整合案例 Version:xml版(myeclipse) 文档结构图: 从底层开始做起: 01.配置web.xml文件 <?xml version ...

  5. Spring+SpringMVC+MyBatis+Maven 服务端XML配置

    项目目录结构 spring-mybatis.xml <?xml version="1.0" encoding="UTF-8"?> <beans ...

  6. spring和mybatis整合配置

    <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...

  7. spring mvc+myBatis配置详解

    一.spring mvc Spring框架(框架即:编程注解+xml配置的方式)MVC是Spring框架的一大特征,Spring框架有三大特征(IOC(依赖注入),AOP(面向切面),MVC(建模M- ...

  8. MyBatis学习 之 一、MyBatis简介与配置MyBatis+Spring+MySql

    目录(?)[-] 一MyBatis简介与配置MyBatisSpringMySql MyBatis简介 MyBatisSpringMySql简单配置 搭建Spring环境 建立MySql数据库 搭建My ...

  9. MyBatis简介与配置MyBatis+Spring+MySql

    MyBatis学习 之 一.MyBatis简介与配置MyBatis+Spring+MySql MyBatis学习 之 二.SQL语句映射文件(1)resultMap MyBatis学习 之 二.SQL ...

随机推荐

  1. MySQL 5.6 安装配置

    mysql 5.6.17下载安装图解_百度经验 http://jingyan.baidu.com/article/4b07be3c67853c48b380f311.html windows 8 系统将 ...

  2. Octave下载

    发福利啦,今天下了半天Octave都没下载下来,最后让一个香港的同学帮忙下好传过来的....放到网盘里造福大家 GNU_Octave_3.8.0-6.dmg 链接: http://pan.baidu. ...

  3. 过虑器 ThreadLocal 权限 监听器 观察者模式

    数据的压缩 GzipOutputStream - > > ByteArrayOutputStream. 以下是在某个servlet中对指定的数据进行压缩 package cn.itcast ...

  4. GPRS连接失败问题

    备注:采用的是SIMCOM的SIM900模块 1. GPRS连接失败问题 2013.08.06测试9台C2000两次,两次之间是机器拿开电池,间隔40分钟左右,每次都出现一台(但不是同一台): ⑴9台 ...

  5. poj 1125 Stockbroker Grapevine(最短路 简单 floyd)

    题目:http://poj.org/problem?id=1125 题意:给出一个社交网络,每个人有几个别人可以传播谣言,传播谣言需要时间.问要使得谣言传播的最快,应该从那个人开始传播谣言以及使得所有 ...

  6. mysql运算符的优先级

    Operator precedences are shown in the following list, from highest precedence to the lowest. Operato ...

  7. Oracle Length 和 Lengthb 函数说明 .(用来判断记录值里是否有中文内容)

    一.官网的说明 http://download.oracle.com/docs/cd/E11882_01/server.112/e26088/functions088.htm#SQLRF00658 P ...

  8. ORACLE【2】:锁机制及解锁

    1. 锁的基本知识 根据要保护的对象不同,oracle的数据锁可以分成以下几类:DML锁,(data locks)数据锁,用于保护数据的完整性:DDL锁(dictionary locks),用于保护数 ...

  9. RPi 2B SD read-only filesytem

    /**************************************************************************** * RPi 2B SD read-only ...

  10. 【 D3.js 高级系列 — 1.1 】 封装文本自动换行

    在[高级 - 第 1.0 章]中讲解了在 SVG 中如何配合使用 text 和 tspan 来实现换行的功能,本文对此功能进行一下封装,以后就可以直接用了. 1. 引用 js 文件 下载地址:mult ...