zoukankan      html  css  js  c++  java
  • spring+springmvc+mybatis中的spring-service.xml配置

    <?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:context="http://www.springframework.org/schema/context"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/context
    https://www.springframework.org/schema/context/spring-context.xsd
    http://www.springframework.org/schema/tx
    https://www.springframework.org/schema/tx/spring-tx.xsd
    http://www.springframework.org/schema/aop
    https://www.springframework.org/schema/aop/spring-aop.xsd">
    <!--1.扫描service下面的包-->
    <context:component-scan base-package="com.kuang.service"/>
    <!--2.将我们所有的业务类,注入到spring,可以通过配置,或者注解实现-->
    <bean id="BookServiceImpl" class="com.kuang.service.BookServiceImpl">
    <property name="bookMapper" ref="bookMapper"/>
    </bean>
    <!--声明式事务配置-->
    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <property name="dataSource" ref="dataSource"/>
    </bean>
    <!--配置事务通知-->
    <tx:advice id="txAdvice" transaction-manager="transactionManager">
    <tx:attributes>
    <!--配置哪些方法使用什么样的事务,配置事务的传播特性-->
    <tx:method name="add" propagation="REQUIRED"/>
    <tx:method name="delete" propagation="REQUIRED"/>
    <tx:method name="update" propagation="REQUIRED"/>
    <tx:method name="search*" propagation="REQUIRED"/>
    <tx:method name="get" read-only="true"/>
    <tx:method name="*" propagation="REQUIRED"/>
    </tx:attributes>
    </tx:advice>
    <!--配置aop织入事务-->
    <aop:config>
    <aop:pointcut id="txPointcut" expression="execution(* com.kuang.dao.*.*(..))"/>
    <aop:advisor advice-ref="txAdvice" pointcut-ref="txPointcut"/>
    </aop:config>

    </beans>

  • 相关阅读:
    六月计划#2B(6.10-6.16)
    set
    六月计划#2A(6.10-6.16)
    Codevs_1166_[NOIP2007]_矩阵取数游戏_(动态规划+高精度)
    7月17日刷题记录 分治Getting!循环比赛日程表
    倍增ST应用 选择客栈(提高组)
    7月16日做题记录 贪心小练~
    三分查找笔记
    倍增笔记ST表
    分治笔记
  • 原文地址:https://www.cnblogs.com/fuqiang-java/p/12292229.html
Copyright © 2011-2022 走看看