zoukankan      html  css  js  c++  java
  • java学习简单笔记20190130

    spring数据库事务

    常用的注解方式@Transactional,可用于类和方法中,配置项中常用的isolation隔离级别,propagation传播行为两个。

    spring+mybatis组合使用事务

    xml配置

    启用扫描机制

    <context:annotation-confg />

    <context:component-sacan base-package="xxxx.xxx.xxx"/>

    数据库连接池

    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">

    <property name=“driverClassName" value="com.mysql.jdbc.Driver" />

    ..........

    集成mybatis

    <bean id="sqlsessionfactory" class="org.mybatis.spring.SqlSessionFactoryBean" >

    <property name="dataSource" ref="dataSource" />

    <property name="configLocation" value="classpath:/mybatis-config.xml" />

    配置事务管理器

    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager" >

    <property name="dataSource" ref="dataSource" />

    使用注解方式事务

    <tx:annotation-driven transaction-manager="transactionManager" />

    采用自动扫描方式生成bean

    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">

    <property name="basePackage" value="xxx.xxx.xxx" />

    <property name="SqlSessionFactoryBeanName" value="SqlSessionFactory" />

    <property name="annotationClass" value="org.springframework.stereotype.Repository" />

    相应的实体类pojo,接口,和mapper.xml对应,并配置mybatis-config.xml引入映射器

    <configuration>

    <mapper resource="com/ss/sqlMapper/RoleMapper.xml">

    -----

    @Repository可理解为数据访问层DAO,@Service可理解为BLL业务逻辑层

  • 相关阅读:
    openfire 介绍安装使用
    android rabbitMQ
    转:socket编程在windows和linux下的区别
    socklen_t在windows和linux平台下的头文件定义
    libevent入门教程
    libevent安装
    《RabbitMQ in action》
    RabbitMQ安装和配置
    node.js模块之http模块
    node.js模块之Buffer模块
  • 原文地址:https://www.cnblogs.com/lofe/p/10340550.html
Copyright © 2011-2022 走看看