//读取spring配置文件
//根据src\test\java\的路径得到配置文件路径
BeanFactory beanFactory = new ClassPathXmlApplicationContext(配置文件);
//通过spring配置文件生成的beanFactory获得SqlSessionFactory
SqlSessionFactory factory = (SqlSessionFactory) beanFactory
.getBean("sqlSessionFactory");
<?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:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
<!-- 使用apache的DBCP连接池 -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<!-- Connection Info -->
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
<property name="url" value="oracle链接" />
<property name="username" value="账号" />
<property name="password" value="密码" />
<!-- Connection Pooling DBCP -->
<property name="initialSize" value="5" />
<property name="maxActive" value="100" />
<property name="maxIdle" value="30" />
<property name="maxWait" value="1000" />
<property name="poolPreparedStatements" value="true" />
<property name="defaultAutoCommit" value="false" />
</bean>
<!-- 这里的dataSource要与sqlSessionFactory的dataSource一致,否则事务无效 -->
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="mapperLocations" value="classpath*:META-INF/mappers/*.xml" />
</bean>
</beans>
相关推荐
基于SpringMVC+Spring+MyBatis个人技术博客系统源码.zip 完整代码,可运行 项目描述 基于SSM实现的一个个人博客系统,适合初学SSM和个人博客制作的同学学习。有了这个源码,直接买了阿里云或腾讯服务器,就可以部署...
SpringMVC+Spring+Mybatis集成开发环境
3、技术框架:Spring 4.1.4.RELEASE、Spring MVC 4.1.4.RELEASE、MyBatis 3.2.8 二、整合思路: 1、设计数据库:设计好表结构,最好符合3NF,使用Generator自动生成Mybatis相关表信息 2、创建Maven项目,按需映入...
使用环境:MyEclipse/Eclipse + Tomcat + MySQL。 使用技术:Spring MVC + Spring + MyBatis / JSP + Servlet + JavaBean + JDBC。
使用环境:MyEclipse/Eclipse + Tomcat + MySQL。 使用技术:Spring MVC + Spring + MyBatis / JSP + Servlet + JavaBean + JDBC。
校社联社团管理系统(Spring MVC+Spring+Mybatis+Redis),用来记录进度,和保存文件,完成一定阶段都上传到小组仓库中。 校社联社团管理系统(Spring MVC+Spring+Mybatis+Redis),用来记录进度,和保存文件,完成...
比较实用的springMvc+spring+Mybatis 实战案例
使用环境:MyEclipse/Eclipse + Tomcat + MySQL。...使用技术:Spring MVC + Spring + MyBatis 或 JSP + Servlet + JavaBean + JDBC。 演示地址:https://ymjin.blog.csdn.net/article/details/120991940
springmvc + spring + mybatis + maven整合配置文件
Java基于Spring+SpringMVC+MyBatis实现的学生信息管理系统源码,SSM+Vue的学生管理系统。 Java基于Spring+SpringMVC+MyBatis实现的学生信息管理系统源码,SSM+Vue的学生管理系统。 Java基于Spring+SpringMVC+...
Struts+Spring+Mybatis+EasyUI(jQuery)注解案例。采用注解的方式跟踪代码依赖性,实现替代配置文件功能。里面包含了平时用的增删改查及分页,分页查询时用的是存储过程,提高了数据库的性能。代码简单、易懂。
struts2+spring+mybatis框架,附带数据库建表,适合初学者搭建环境。
Struts2+maven+spring+mybatis整合,并实现注册功能实例。
《Spring+MyBatis企业应用实战》适合有较好的Java 编程基础,JSP、Servlet、JDBC 基础,Spring 框架基础的读者,尤其适合于对Spring MVC 和MyBatis 了解不够深入,或对Spring MVC+MyBatis 整合开发不太熟悉的开发...
spring+mybatis+springmvc maven框架,单模块,导入就可以使用,里面有一个user的增删查改,大家拿来修改就可以使用
MVC框架springmvc+spring+mybatis附带有MySQL的代码文件,还有mybatis的生成插件generator及生成方法,代码的联表的增删改查
通过SpringMvc+Spring+Mybatis+Maven整合,学习用maven搭建框架
《spring+mybatis 企业应用实战》源码、类库全资料
spring+mybatis企业应用实战项目源码(源码+sql),使用jdk8+tomcat8,jar包完整,下载可以就可以运行
搭建SSM(springMVC+spring+mybatis)框架的maven项目