Spring 和 mybaits 整合
来源:互联网 发布:淘宝网卖家信誉 编辑:程序博客网 时间:2024/05/22 20:24
本文主要介绍Spring与Mybatis三种常用整合方法,需要的整合架包是mybatis-spring.jar,可通过链接
http://code.google.com/p/mybatis/下载到。
1、采用数据映射器(MapperFactoryBean)的方式,不用写mybatis映射文件,采用注解方式提供相应的sql语句和输入参数。
(1)Spring配置文件:
<!-- 引入jdbc配置文件 -->
<context:property-placeholder location="jdbc.properties"/>
<!--创建jdbc数据源 -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="${driver}"/>
<property name="url" value="${url}"/>
<property name="username" value="${username}"/>
<property name="password" value="${password}"/>
<property name="initialSize" value="${initialSize}"/>
<property name="maxActive" value="${maxActive}"/>
<property name="maxIdle" value="${maxIdle}"/>
<property name="minIdle" value="${minIdle}"/>
</bean>
<!-- 创建SqlSessionFactory,同时指定数据源-->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
</bean>
<!--创建数据映射器,数据映射器必须为接口-->
<bean id="userMapper" class="org.mybatis.spring.mapper.MapperFactoryBean">
<property name="mapperInterface" value="com.xxt.ibatis.dbcp.dao.UserMapper" />
<property name="sqlSessionFactory" ref="sqlSessionFactory" />
</bean>
<bean id="userDaoImpl2" class="com.xxt.ibatis.dbcp.dao.impl.UserDaoImpl2">
<property name="userMapper" ref="userMapper"/>
</bean>
- Spring 和 mybaits 整合
- spring和mybaits整合
- spring-boot-mybaits 整合
- springmvc和mybaits整合案例
- Spring 学习日记 (四) Spring 整合Mybaits 和 struts2 框架的配置文件
- Eclipse Meaven Spring SpringMVC Mybaits整合
- Spring+SpringMVC+MyBaits+Druid+Maven项目整合
- spring boot 整合 mybaits之XML
- Spring Boot教程五:整合mybaits
- 整合spring和myBaits时候报这个错是怎么回事?跪求解答
- mybaits 整合
- Spring整合Mybaits实现ehcache 注解查询缓存
- Spring-mybaits-mina整合,启动多端口监听
- spring-boot系列——与mybaits整合
- Spring整合Mybaits实现ehcache 注解查询缓存
- springmvc和mybaits整合(五)-商品查询controller
- redis-cluster整合mybaits
- springmvc+mybaits整合
- tree命令详解
- Address already in use Try changing the registry value
- StrictMode的使用(转)
- netlink知识
- org.hibernate.StaleStateException:Batch update returned unexpected row count from update [0]; actua
- Spring 和 mybaits 整合
- js日期时间比较
- 图文版stagefright arch 03 -- how to choose decoder
- 使用Web服务
- 西安一村庄集资买客车当公交 交管称非法应取缔
- 笔试题收集
- Mac 下配置php环境
- tell function
- 图文版stagefright arch 04 -- video buffer Empty/Fill