spring4 整合 mybatis3 配置文件
2019独角兽企业重金招聘Python工程师标准>>>
spring-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xmlns="http://www.springframework.org/schema/beans"xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"><context:property-placeholder location="classpath:db.properties"/><context:component-scan base-package="xx.xx"/><context:annotation-config/><bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"><property name="location" value="db.properties"/></bean><bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"><property name="driverClass" value="${db.driver}"/><property name="jdbcUrl" value="${db.url}"/><property name="user" value="${db.username}"/><property name="password" value="${db.password}"/></bean><bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"><property name="dataSource" ref="dataSource"/></bean><!-- 整合 mybatis --><bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"><property name="dataSource" ref="dataSource"/><property name="configLocation" value="classpath:mybatis-config.xml"></property><property name="mapperLocations" value="classpath:mapper/*.xml"/></bean><bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"><property name="annotationClass" value="org.springframework.stereotype.Repository"/><property name="basePackage" value="xx.dao"/></bean><!-- 事务配置 --><bean name="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"><property name="dataSource" ref="dataSource"></property></bean><tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/>
</beans>
mybatis-config.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN""http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration><typeAliases><package name="xx.model"/></typeAliases></configuration>
声明式事务,好强大的感觉。。。
转载于:https://my.oschina.net/cwzhang/blog/480287
spring4 整合 mybatis3 配置文件相关推荐
- Spring集成Mybatis,spring4.x整合Mybatis3.x
Spring集成Mybatis,spring4.x整合Mybatis3.x ============================== 蕃薯耀 2018年3月14日 http://www.cnblo ...
- Spring4整合Hibernate4出现的错误的解决
今天在使用Spring4整合Hibernate4过程中出现错误 org.hibernate.HibernateException: Could not obtain transaction-synch ...
- SpringBoot整合Mybatis3 Dynamic Sql(IDEA)
SpringBoot整合Mybatis3 Dynamic Sql(IDEA) Mybatis Dynamic Sql与以前TargetRuntime相比较: 移除了XXXExamle类和xml文件,代 ...
- Spring4 整合 Hibernate3 基本使用(通过注入 SessionFactory)
Spring4 整合 Hibernate3 基本使用(通过注入 SessionFactory) Spring4 整合 Hibernate3 基本使用通过注入 SessionFactory 步骤 1 导 ...
- Mybatis与Spring整合之配置文件方式
Mybatis与Spring整合之配置文件 案例制作步骤--基础准备工作 ⚫ 环境准备 导入Spring坐标,MyBatis坐标,MySQL坐标,Druid坐标 ⚫ 业务类与接口准备 创建数据库表,并 ...
- mybatis3 配置文件解析
mybatis3 配置文件解析 2013-05-08 19:43 34388人阅读 评论(0) 收藏 举报 分类: mybatis3(19) 目录(?)[+] 配置文件的基本结构 configurat ...
- springBoot中shiro与Redis整合的配置文件
springBoot中shiro与Redis整合的配置文件 整合依赖: < ...
- Spring3 整合MyBatis3 配置多数据源 动态选择SqlSessionFactory
一.摘要 上两篇文章分别介绍了Spring3.3 整合 Hibernate3.MyBatis3.2 配置多数据源/动态切换数据源 方法 和 Spring3 整合Hibernate3.5 动态切换Ses ...
- SSM整合时配置文件的编写
编写web.xml 1.配置项目初始化时启动Spring容器 传递参数,spring配置文件的位置 <context-param><param-name>contextConf ...
最新文章
- DllImport dll中有些啥函数 及 dll中是否用到了别的dll
- Debian/Ubuntu 报错解决:Command 'ifconfig' not found, but can be installed with
- C++ Primer 5th笔记(chap 15 OOP)抽象基类
- 深度学习网络模型AlexNet
- docker选择安装位置_如何使用docker 1.13版本更改centos 7中的docker安装目录
- SQL Server定时执行SQL语句
- QuickSort 快速排序
- 2020-11-02 联想 Yoga Duet IML 2020
- 一键在线生成朋友圈转发点赞截图教程
- 新城易居程伟健:民宿集群,正在走向产业标准化的趋势!
- 联通光猫后台 192.168.1.1登录
- android从相册或拍照获取照片第三方开源库TakePhoto
- IBM技术论坛:使用 Cobertura 和反射机制提高单元测试中的代码覆盖率
- Linux的入门学习
- 什么是反射?有什么作用?
- 一招解决MySql Specified key was too long; max key length is 767 bytes
- 运用hadoop计算TF-IDF
- 【win8系统开机自动拨号连接宽带图文教程】
- STM32CubeMX的正交编码器encoder
- wxPython 2.8 XRC Resource Editor Bug