1、采用数据映射器(MapperFactoryBean)的方式,不用写mybatis映射文件,采用注解方式提供相应的sql语句和输入参数。
  (1)Spring配置文件:

  1. <!-- 引入jdbc配置文件 -->
  2. <context:property-placeholder location="jdbc.properties"/>
  3. <!--创建jdbc数据源 -->
  4. <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
  5. <property name="driverClassName" value="${driver}"/>
  6. <property name="url" value="${url}"/>
  7. <property name="username" value="${username}"/>
  8. <property name="password" value="${password}"/>
  9. <property name="initialSize" value="${initialSize}"/>
  10. <property name="maxActive" value="${maxActive}"/>
  11. <property name="maxIdle" value="${maxIdle}"/>
  12. <property name="minIdle" value="${minIdle}"/>
  13. </bean>
  14. <!-- 创建SqlSessionFactory,同时指定数据源-->
  15. <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
  16. <property name="dataSource" ref="dataSource" />
  17. </bean>
  18. <!--创建数据映射器,数据映射器必须为接口-->
  19. <bean id="userMapper" class="org.mybatis.spring.mapper.MapperFactoryBean">
  20. <property name="mapperInterface" value="com.xxt.ibatis.dbcp.dao.UserMapper" />
  21. <property name="sqlSessionFactory" ref="sqlSessionFactory" />
  22. </bean>
  23. <bean id="userDaoImpl2" class="com.xxt.ibatis.dbcp.dao.impl.UserDaoImpl2">
  24. <property name="userMapper" ref="userMapper"/>
  25. </bean>

Spring学习笔记:spring与mybatis四种整合方法的更多相关文章

  1. spring与mybatis四种整合方法

    转载: 1.采用数据映射器(MapperFactoryBean)的方式,不用写mybatis映射文件,采用注解方式提供相应的sql语句和输入参数.   (1)Spring配置文件: <!-- 引 ...

  2. spring与mybatis三种整合方法

    spring与mybatis三种整合方法 本文主要介绍Spring与Mybatis三种常用整合方法,需要的整合架包是mybatis-spring.jar,可通过链接 http://code.googl ...

  3. spring与mybatis五种整合方法

    1.采用数据映射器(MapperFactoryBean)的方式 不用写mybatis映射文件,采用注解方式提供相应的sql语句和输入参数.  (1)Spring配置文件: <!-- 引入jdbc ...

  4. Spring学习笔记--spring+mybatis集成

    前言: 技术的发展, 真的是日新月异. 作为javaer, 都不约而同地抛弃裸写jdbc代码, 而用各种持久化框架. 从hibernate, Spring的JDBCTemplate, 到ibatis, ...

  5. Spring学习笔记--Spring IOC

    沿着我们上一篇的学习笔记,我们继续通过代码学习IOC这一设计思想. 6.Hello类 第一步:首先创建一个类Hello package cn.sxt.bean; public class Hello ...

  6. Android学习笔记(八)——四种基本布局

    //此系列博文是<第一行Android代码>的学习笔记,如有错漏,欢迎指正! 布局是一种可用于放置很多控件的容器,它可以按照一定的规律调整内部控件的位置,或是嵌套子布局,从而编写出精美的界 ...

  7. Spring学习笔记——Spring依赖注入原理分析

    我们知道Spring的依赖注入有四种方式,各自是get/set方法注入.构造器注入.静态工厂方法注入.实例工厂方法注入 以下我们先分析下这几种注入方式 1.get/set方法注入 public cla ...

  8. Spring学习笔记-Spring之旅-01

    使用Spring简化JAVA开发 Spring的四种关键策略: ●基于POJO的轻量级和最小侵入式编程: ●通过依赖注入(DI)和面向接口实现松耦合: ●基于切面(AOP)和惯例进行声明式编程. ●通 ...

  9. Spring学习笔记—Spring之旅

    1.Spring简介     Spring是一个开源框架,最早由Rod Johnson创建,并在<Expert One-on-One:J2EE Design and Development> ...

随机推荐

  1. [bzoj1951] [Sdoi2010]古代猪文 费马小定理+Lucas定理+CRT

    Description "在那山的那边海的那边有一群小肥猪.他们活泼又聪明,他们调皮又灵敏.他们自由自在生活在那绿色的大草坪,他们善良勇敢相互都关心--" --选自猪王国民歌 很久 ...

  2. luoguP5068 [Ynoi2015]我回来了

    https://www.luogu.org/problemnew/show/P5068 ynoi 中的良心题啊 考虑用 bitset 来维护里一个点距离小于 $ y_i $ 的点,那么答案就是一堆 b ...

  3. 关于CentOS-6的默认带的mysql启动和安装问题

    http://blog.csdn.net/arrowzz/article/details/24439731 以下纯复制粘贴: 一开始想自己一步一步从编译开始搭建一个lanmp环境: 从鸟哥的linux ...

  4. Keil软件编程问题归总

    Q:KEIL.uVision.RealView.MDK.KEIL C51之间的关系纠葛(比较区别)? A: KEIL是公司的名称,有时候也指KEIL公司的所有软件开发工具,目前2005年Keil由AR ...

  5. Mysql备份之Innobakcupex&Xtrabackup

                       一.innobackupex备份工具 基本选项 --compress:该选项表示压缩innodb数据文件的备份. --compress-threads:该选项表示 ...

  6. Hibernate 连接数据库,数据库返回数据超过限制报错

    1.packet for query is too large 1024 >. you can change this value on the server mysql max_allowed ...

  7. Axis2 Web Service Development & Deployment Guide(Axis2使用)

    主要内容: 记录关于Axis2的使用,通过WSDL文件生成Web service的客户端和服务器端的过程. 目录: Requirement(必备工具) Development - Client Gen ...

  8. Error: Another program is already listening on a port that one of our HTTP servers is configured to use. Shut this program down first before starting

    解决方法: find / -name supervisor.sock unlink /name/supervisor.sock 2. www-data 用户是干什么用的 3.如何通过superviso ...

  9. PHP在 win7 64位 旗舰版 报错 Call to undefined function curl_init()

    代码在ubuntu下无缝运行OK 转到我的win7 64位 期间 学习机上 报错: Call to undefined function curl_init() 因为用到curl 远程抓取数据. 所以 ...

  10. Error处理:/bin/bash^M: 坏的解释器: 没有该文件或目录(bad interpreter: No such file or directory)

    在Linux下编译运行脚本的时候出现”/bin/bash^M: 坏的解释器: 没有那个文件或目录(bad interpreter: No such file or directory)“这样的错误. ...