spring和mybatis整合配置
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.1.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd">
<!--开启自动扫描 -->
<context:component-scan base-package="com.pb.zte"/>
<!--引入JDBC配置文件 -->
<bean id="propertyPlaceholderConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="classpath:jdbc.properties"/>
</bean>
<!--数据源 -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<!--驱动 -->
<property name="driverClassName" value="${driver}"/>
<!--URL -->
<property name="url" value="${url}"/>
<!--username -->
<property name="username" value="${username}"/>
<!--password -->
<property name="password" value="${password}"/>
</bean>
<!--sqlSessionFactory spring和MyBatis完美整合,不需要mybatis的配置映射文件-->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<!--注入数据源 -->
<property name="dataSource" ref="dataSource"/>
<!--扫描所有Dao的实现类xml 自动扫描mapping.xml文件-->
<property name="mapperLocations" value="classpath:com/pb/zte/mapping/*.xml"/>
</bean>
<!--为所有DAO层注入sqlSessionFactory -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<!--基本包Dao层所在包最上一层 -->
<property name="basePackage" value="com.pb.zte.mapper"/>
<!--注入sqlSessionFactoryBeanName -->
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property>
</bean> <!--数据源事务管理 -->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<!--注入数据源 -->
<property name="dataSource" ref="dataSource"/>
</bean> </beans>
spring和mybatis整合配置的更多相关文章
- SSM Spring +SpringMVC+Mybatis 整合配置 及pom.xml
SSM Spring +SpringMVC+Mybatis 配置 及pom.xml SSM框架(spring+springMVC+Mybatis) pom.xml文件 maven下的ssm整合配置步骤
- Spring与Mybatis整合配置
Mybatis核心配置文件: 配置文件内可以不写内容 <?xml version="1.0" encoding="UTF-8" ?> <!DO ...
- Spring+SpringMVC+MyBatis整合配置
前端控制器 web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app version=& ...
- spring, spring mvc, mybatis整合文件配置详解
转自:http://www.cnblogs.com/wxisme/p/4924561.html 使用SSM框架做了几个小项目了,感觉还不错是时候总结一下了.先总结一下SSM整合的文件配置.其实具体的用 ...
- Spring+springmvc+Mybatis整合案例 xml配置版(myeclipse)详细版
Spring+springmvc+Mybatis整合案例 Version:xml版(myeclipse) 文档结构图: 从底层开始做起: 01.配置web.xml文件 <?xml version ...
- idea spring+springmvc+mybatis环境配置整合详解
idea spring+springmvc+mybatis环境配置整合详解 1.配置整合前所需准备的环境: 1.1:jdk1.8 1.2:idea2017.1.5 1.3:Maven 3.5.2 2. ...
- Spring+springmvc+Mybatis整合案例 annotation版(myeclipse)详细版
Spring+springmvc+Mybatis整合案例 Version:annotation版 文档结构图: 从底层开始做起: 01.配置web.xml文件 <?xml version=&qu ...
- Spring与Mybatis整合的MapperScannerConfigurer处理过程源码分析
前言 本文将分析mybatis与spring整合的MapperScannerConfigurer的底层原理,之前已经分析过java中实现动态,可以使用jdk自带api和cglib第三方库生成动态代理. ...
- Mybatis学习--spring和Mybatis整合
简介 在前面写测试代码的时候,不管是基于原始dao还是Mapper接口开发都有许多的重复代码,将spring和mybatis整合可以减少这个重复代码,通过spring的模板方法模式,将这些重复的代码进 ...
随机推荐
- 理解 JS 回调函数中的 this
任何变量或对象都有其赖以生存的上下文.如果简单地将对象理解为一段代码,那么对象处在不同的上下文,这段代码也会执行出不同的结果. 例如,我们定义一个函数 getUrl 和一个对象 pseudoWindo ...
- [Ubuntu] bash: warning: setlocale: LC_ALL: cannot change locale
问题症状 -bash: warning: setlocale: LC_ALL: cannot change locale (en_US.utf8) 解决方法 本地化是指不同地区用户在键盘上输入不同语言 ...
- 《微信小程序七日谈》- 第二天:你可能要抛弃原来的响应式开发思维
<微信小程序七日谈>系列文章: 第一天:人生若只如初见: 第二天:你可能要抛弃原来的响应式开发思维: 第三天:玩转Page组件的生命周期: 第四天:页面路径最多五层?导航可以这么玩 上篇文 ...
- Node.app – 用于 iOS App 开发的 Node.js 解释器
Node.app 是用于 iOS 开发的 Node.js 解释器,它允许最大的代码重用和快速创新,占用资源很少,为您的移动应用程序提供 Node.js 兼容的 JavaScript API.你的客户甚 ...
- 订餐APP第二次sprint+燃尽图
MY-HR 成员: 角色分配 学号 博客园 团队贡献分 围观其他小组评论 丘惠敏 PM项目经理 201406114203 http://www.cnblogs.com/qiuhuimin/ 21 ht ...
- mysql 判断表字段或索引是否存在,然后修改
判断字段是否存在: DROP PROCEDURE IF EXISTS schema_change; DELIMITER // CREATE PROCEDURE schema_change() BEGI ...
- 在ASP.NET MVC环境中使用加密与解密
在.NET Framework 4.5的NET框架中,在程序中加密与解密很方便.现在均学习ASP.NET MVC程序了,因此Insus.NET也在此写个学习的例子.在需要时可以参考与查阅. 写一个Ut ...
- 【iOS】FMDB/SQLCipher数据库加解密,迁移
2016-04-19更新:本文代码可能有些问题,请移步 http://zhengbomo.github.io/2016-04-18/sqlcipher-start/ 查看 sqlite应用几乎在所有的 ...
- 数组(Array)的使用方法
本文内容: 1.概述 2.数组基础 3.结合for循环与arr.length,在数组尾部插入数值 4.利用'concat','join'实 ...
- C#基本概念列举说明
1. 关键字 在C#代码中常常使用关键字,关键字也叫保留字,是对C#有特定意义的字符串.关键字在Visual Studio 环境的代码视图中默认以蓝色显示.例如,代码中的using.name ...