第一种:

<!-- 配置sqlsession -->
<bean id="sqlsessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="configLocation" value="classpath:SqlSessionMap.xml" />
</bean>
<!-- 配置mybatis代理 -->
<bean id="mapperFactoryBean" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="sqlSessionFactoryBeanName" value="sqlsessionFactory" />
<property name="basePackage" value="com.ssm.mapper" />
</bean>

第二种:

<!-- 配置sqlsessionFactory -->
<bean id="sessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="configLocation" value="classpath:mybatisMapConfig.xml"/>
<property name="mapperLocations" value="classpath:mapper/*Mapper.xml"/>
</bean>
<!--配置动态代理 -->
<bean id="scannerConfigurer" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="sqlSessionFactoryBeanName" value="sessionFactory"/>
<property name="basePackage" value="com.xyh.ssm.*.dao"/>
</bean>

spring整合mybatis二种配置的更多相关文章

  1. strut1.X和spring整合的二种方法

    第一种集成方法 原理:在Action中取得BeanFactory对象,然后通过BeanFactory获取业务逻辑对象 缺点:产生了依赖,spring的类在action中产生了依赖查找.(注意和依赖注入 ...

  2. spring整合mybatis是如何配置事务的?

    作者:郭无心链接:https://www.zhihu.com/question/30206875/answer/84675373来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明 ...

  3. spring 整合 mybatis 中数据源的几种配置方式

    因为spring 整合mybatis的过程中, 有好几种整合方式,尤其是数据源那块,经常看到不一样的配置方式,总感觉有点乱,所以今天有空总结下. 一.采用org.mybatis.spring.mapp ...

  4. Spring学习总结(五)——Spring整合MyBatis(Maven+MySQL)二

    接着上一篇博客<Spring整合MyBatis(Maven+MySQL)一>继续. Spring的开放性和扩张性在J2EE应用领域得到了充分的证明,与其他优秀框架无缝的集成是Spring最 ...

  5. spring整合mybatis(hibernate)配置

    一.Spring整合配置Mybatis spring整合mybatis可以不需要mybatis-config.xml配置文件,直接通过spring配置文件一步到位.一般需要具备如下几个基本配置. 1. ...

  6. spring与mybatis五种整合方法

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

  7. Spring学习笔记:Spring整合Mybatis(mybatis-spring.jar)(二:mybatis整合spring)

    http://blog.csdn.net/qq598535550/article/details/51703190 二.Spring整合mybatis其实是在mybatis的基础上实现Spring框架 ...

  8. spring基础:什么是框架,框架优势,spring优势,耦合内聚,什么是Ioc,IOC配置,set注入,第三方资源配置,综合案例spring整合mybatis实现

    知识点梳理 课堂讲义 1)Spring简介 1.1)什么是框架 源自于建筑学,隶属土木工程,后发展到软件工程领域 软件工程中框架的特点: 经过验证 具有一定功能 半成品 1.2)框架的优势 提高开发效 ...

  9. spring整合mybatis,ioc容器及声明式事务配置

    步骤: 1.创建jdbc.properties文件,用来管理存放连接数据库的相关信息 jdbc.properties:jdbc.user=root jdbc.password=123456 jdbc. ...

随机推荐

  1. pom.xml文件释义

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/20 ...

  2. IIS7/8下提示 HTTP 错误 404.13 - Not Found 请求筛选模块被配置为拒绝超过请求内容长度的请求

    IIS7的设置和IIS6有很多不同之处,这里提到的的是一个上传附件大小设置的问题. HTTP 错误 404.13 - Not Found 请求筛选模块被配置为拒绝超过请求内容长度的请求. 原因:Web ...

  3. Gmapping笔记

    2D-slam 激光slam: 开源代码的比较HectorSLAM Gmapping KartoSLAM CoreSLAM LagoSLAM 作者:kint_zhao 原文:https://blog. ...

  4. JavaScript 引用错误

    在学习vue时 出现无法实现效果原始设置 <script src="js/lib/vue2.min.js"/><script src="js/lib/v ...

  5. 使用tcpreply对DPDK进行压力测试(一台主机,2张网卡压测)

    使用tcpreply对DPDK进行压力测试 过往风萤 关注 2018.05.18 14:35* 字数 273 阅读 2评论 0喜欢 0 小公司没有testcenter之类的打流工具,并且内网流量比较小 ...

  6. python基础之Day24

    1.补充内置函数 2.反射 什么是? 通过字符串操作类或者对象的属性 hasattri(a,"b")  判断能否访问到a.b setattri(a,"b",c) ...

  7. Django使用第三方模块django-password-reset重置密码

    网上关于django第三方模块django-password-reset重置密码的几篇博客有一个严重的bug 见博客:https://blog.csdn.net/qq_42820268/article ...

  8. javaMail的使用以及trying to connect to host "1xxx@163.com", port 25, isSSL false异常

    最近项目用到邮件系统,开始了解javaMail...话不多说先上代码: pom依赖: <!--    邮件  https://mvnrepository.com/artifact/javax.m ...

  9. kenlm的使用

    1.训练模型 install_path/bin/lmplz -o -S % -T /temp <text >text.arpa -o  表示n_gram 中的n(必选) -S  内存使用( ...

  10. asp:DropDownList 使用

    <asp:DropDownList ID="DropDownList1" runat="server" onchange="return My_ ...