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. 李洪强iOS开发之宏定义方法来初始化一个单例对象

    单例的使用: .m 为了方便实用,只要将以下代码定义在header文件或者.pch文件即可: // .h #define singleton_interface(class) + (instancet ...

  2. SDUT2157——Greatest Number(STL二分查找)

    Greatest Number 题目描述Saya likes math, because she think math can make her cleverer.One day, Kudo invi ...

  3. C#+SQL数据库备份和还原

    使用前要导入SQLDMO.dll(在com组件中导入Microsoft SQLDMO Object Library即可) /// /// DbOper类,主要应用SQLDMO实现对Microsoft ...

  4. Android之AlertDialog.Builder详解

    import android.app.Activity; import android.app.AlertDialog; import android.content.DialogInterface; ...

  5. python学习链接

    http://www.cnblogs.com/dkblog/archive/2011/06/24/2089026.html 异常处理 http://xiagu1.iteye.com/blog/6195 ...

  6. R语言学习笔记:怎么从txt中读入数据

    1   从该链接中下载测试数据,http://pan.baidu.com/share/link?shareid=3322971616&uk=3862050759   2   把测试文件Anal ...

  7. 深入理解ob_flush和flush的区别

    ob_flush/flush在手册中的描述, 都是刷新输出缓冲区, 并且还需要配套使用, 所以会导致很多人迷惑… 其实, 他们俩的操作对象不同, 有些情况下, flush根本不做什么事情.. ob_* ...

  8. Vim的tag系统

    tag标识符存储在ctags等程序生成的文件里 :tag和<C-]>命令跳转到光标所在符号(若光标不再符号上则为右边第一个符号)的定义处 还有g+鼠标左键和<C-鼠标左键> & ...

  9. Django提供后台接口的跨域问题

    --> Django跨域 当使用Django仅用来开发后端接口,为前端提供JSON数据的时候,不可避免的要接受前端的POST请求.虽然Django以其强大易用的特定使用很广泛,但在跨域问题上却让 ...

  10. I.MX6 build.prop

    /************************************************************************ * I.MX6 build.prop * 说明: * ...