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 配置文件相关推荐

  1. Spring集成Mybatis,spring4.x整合Mybatis3.x

    Spring集成Mybatis,spring4.x整合Mybatis3.x ============================== 蕃薯耀 2018年3月14日 http://www.cnblo ...

  2. Spring4整合Hibernate4出现的错误的解决

    今天在使用Spring4整合Hibernate4过程中出现错误 org.hibernate.HibernateException: Could not obtain transaction-synch ...

  3. SpringBoot整合Mybatis3 Dynamic Sql(IDEA)

    SpringBoot整合Mybatis3 Dynamic Sql(IDEA) Mybatis Dynamic Sql与以前TargetRuntime相比较: 移除了XXXExamle类和xml文件,代 ...

  4. Spring4 整合 Hibernate3 基本使用(通过注入 SessionFactory)

    Spring4 整合 Hibernate3 基本使用(通过注入 SessionFactory) Spring4 整合 Hibernate3 基本使用通过注入 SessionFactory 步骤 1 导 ...

  5. Mybatis与Spring整合之配置文件方式

    Mybatis与Spring整合之配置文件 案例制作步骤--基础准备工作 ⚫ 环境准备 导入Spring坐标,MyBatis坐标,MySQL坐标,Druid坐标 ⚫ 业务类与接口准备 创建数据库表,并 ...

  6. mybatis3 配置文件解析

    mybatis3 配置文件解析 2013-05-08 19:43 34388人阅读 评论(0) 收藏 举报 分类: mybatis3(19) 目录(?)[+] 配置文件的基本结构 configurat ...

  7. springBoot中shiro与Redis整合的配置文件

                                                                 springBoot中shiro与Redis整合的配置文件 整合依赖: < ...

  8. Spring3 整合MyBatis3 配置多数据源 动态选择SqlSessionFactory

    一.摘要 上两篇文章分别介绍了Spring3.3 整合 Hibernate3.MyBatis3.2 配置多数据源/动态切换数据源 方法 和 Spring3 整合Hibernate3.5 动态切换Ses ...

  9. SSM整合时配置文件的编写

    编写web.xml 1.配置项目初始化时启动Spring容器 传递参数,spring配置文件的位置 <context-param><param-name>contextConf ...

最新文章

  1. DllImport dll中有些啥函数 及 dll中是否用到了别的dll
  2. Debian/Ubuntu 报错解决:Command 'ifconfig' not found, but can be installed with
  3. C++ Primer 5th笔记(chap 15 OOP)抽象基类
  4. 深度学习网络模型AlexNet
  5. docker选择安装位置_如何使用docker 1.13版本更改centos 7中的docker安装目录
  6. SQL Server定时执行SQL语句
  7. QuickSort 快速排序
  8. 2020-11-02 联想 Yoga Duet IML 2020
  9. 一键在线生成朋友圈转发点赞截图教程
  10. 新城易居程伟健:民宿集群,正在走向产业标准化的趋势!
  11. 联通光猫后台 192.168.1.1登录
  12. android从相册或拍照获取照片第三方开源库TakePhoto
  13. IBM技术论坛:使用 Cobertura 和反射机制提高单元测试中的代码覆盖率
  14. Linux的入门学习
  15. 什么是反射?有什么作用?
  16. 一招解决MySql Specified key was too long; max key length is 767 bytes
  17. 运用hadoop计算TF-IDF
  18. 【win8系统开机自动拨号连接宽带图文教程】
  19. STM32CubeMX的正交编码器encoder
  20. wxPython 2.8 XRC Resource Editor Bug

热门文章

  1. php拓展板块 按需开启,php如何按需加载方式来增加程序的灵活度
  2. Halcon中数据的四舍五入、取整、有效数字以及和字符串之间的转换
  3. Loadrunner压测时,出现的问题汇总
  4. React Native知识2-Text组件
  5. EntityFramework之原始查询及性能优化(六)
  6. sublime使用总结
  7. 《1---关于解决MySQL在控制台插入中文乱码问题》
  8. orangepi找不到GPIO的解决方法
  9. 解决从本地文件系统上传到HDFS时的权限问题
  10. 微信小程序首页index.js获取不到app.js中动态设置的globalData的原因以及解决方法