spring配置mybatis的sqlsessionfactory
<!--读入配置文件 -->
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<value>classpath*:jdbc.properties</value>
</property>
</bean> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="${jdbc.driverClassName}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
</bean>
<!-- spring和MyBatis完美整合,不需要mybatis的配置映射文件 -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<!-- 文件映射器,指定类文件 -->
<property name="configLocation" value="classpath:mybatis/mybatis-config.xml"/>
<!-- 自动扫描mapping.xml文件 -->
<property name="mapperLocations" value="classpath:com/chinasoft/ssm/mapper/*.xml"></property>
</bean> <!--下面两种方法,一种是自动是扫描对应的service类,一种是通过注入sqlsessionFactory的方式来获取一个SqlsessionTemplate-->
<!-- DAO接口所在包名,Spring会自动查找其下的类 -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<!--set注入-->
<property name="basePackage" value="com.chinasoft.ssm.dao"/>
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property>
</bean>
<!-- 配置SqlSessionTemplate -->
<bean id="sqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate">
<!-- 通过构造函数注入 -->
<constructor-arg name="sqlSessionFactory" ref="sqlSessionFactory" />
</bean>
spring配置mybatis的sqlsessionfactory的更多相关文章
- Spring配置MyBatis
1.MyBatis配置文件(mybatis-config) <?xml version="1.0" encoding="UTF-8"?> <! ...
- Maven Web项目配置Mybatis出现SqlSessionFactory错误的解决方案
一.错误现象 严重: Context initialization failed org.springframework.beans.factory.BeanCreationException: Er ...
- 关于Spring和mybatis的整合
Spring同Mybatis的整合 1.引入相应的jar包.(Mybatis的jar包,Spring的jar包,mybatis-spring-1.1.1.jar). 2.编写相应的包(三层的包).搭建 ...
- spring springmvc mybatis 整合
环境 apache-tomcat-8.0.33.jdk1.8.0_05 maven Dynamic Web Module 2.5 1.各个xml配置文件的配置 (1)pom.xml 配置清单文件 连接 ...
- Spring配置,JDBC数据源及事务
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...
- Spring+SpringMVC+MyBatis+easyUI整合基础篇(三)搭建步骤
框架介绍: 主角即Spring.SpringMVC.MyBatis.easyUI,大家应该也都有所了解,概念性的东西就不写了,有万能的百度. 工作环境: jdk 1.7 m ...
- (4)Maven快速入门_4在Spring+SpringMVC+MyBatis+Oracle+Maven框架整合运行在Tomcat8中
利用Maven 创建Spring+SpringMVC+MyBatis+Oracle 项目 分了三个项目 Dao (jar) Service (jar) Controller (web) ...
- spring+springMVC+mybatis简单整合
spring+springMVC+mybatis简单整合, springMVC框架是spring的子项目,所以框架的整合方式为,spring+Mybatis或springMVC+mybatis. 三大 ...
- Spring+SpringMVC+MyBatis整合基础篇(三)搭建步骤
作者:13GitHub:https://github.com/ZHENFENG13版权声明:本文为原创文章,未经允许不得转载. 框架介绍 Spring SpringMVC MyBatis easyUI ...
随机推荐
- PAT甲级【2019年3月考题】——A1157 Anniversary【25】
Zhejiang University is about to celebrate her 122th anniversary in 2019. To prepare for the celebrat ...
- 转 Page Object模式
Page Object模式是Selenium中的一种测试设计模式,主要是将每一个页面设计为一个Class,其中包含页面中需要测试的元素(按钮,输入框,标题 等),这样在Selenium测试页面中可以通 ...
- Windows server 2016远程桌面登录和修改3389端口
- Codeforce 464A. No to Palindromes!
A. No to Palindromes! time limit per test 1 second memory limit per test 256 megabytes input standar ...
- python3.6:AttributeError: 'generator' object has no attribute 'next'
环境:PyCharm+Anaconda python版本:3.6 协程测试: #!/usr/bin/env python # -*- coding:utf-8 -*- import time def ...
- python3 requests库学习笔记(MOOC网)
奏:HTTP协议对资源的操作 方法说明:GET 请求获取URL位置的资源HEAD 请求获取URL位置资源的响应消息报告,即获得该资源的头部信息POST 请求向URL位置的资源后附加新的数据PUT 请求 ...
- spring3.0+struts2+ibatis整合
User.xml <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE sqlMap PUBLI ...
- 箭头函数与普通function的区别
1. 箭头函数没有自己的this,它里面的this是继承所属上下文中的this,而且使用call与apply都无法改变 let obj = { name: 'obj' } function fn1() ...
- Angular的一些常用命令
Angular的一些常用命令 cmd中创建项目: ng new taskmgr -si --style=scss //先不安装依赖,si 为skip install material需要scss样式的 ...
- while 循环语句举例