zoukankan      html  css  js  c++  java
  • springAOP练习及提示

    1.练xml方式增强处理
    第一种:xml定义四个方法增强 提示:aop:config aop:pointcut aop:before
    第二种:xml定义around方法增强 提示: aop:config aop:pointcut aop:around
    第三种:xml定义 提示: 继承的类MethodInterceptor增强 aop:config aop:pointcut aop:advisor
    2.练注解方式增强处理
    xml中开启注解方式增强处理

    提示:
    	<!--开启增强注解支持-->
    	<aop:aspectj-autoproxy></aop:aspectj-autoproxy>
    	@Aspect @Component @Pointcut @Before @Around 等
    

    3.练习事务
    需要事务管理器和dataSource
    通过xml定义四个方法管理事务
    通过注解方式控制事务
    3.练习声明式事务
    练xml方式声明式事务
    提示:
    需要配置事务管理器 mybatis事务管理器DataSourceTransactionManager
    配置事务增强处理 <tx:advice id="被切面(aop:advisor)所引用" transaction-manager="关联事务管理器">
    配置
    aop:config
    <aop:pointcut id="pc" expression="execution(* com.itheima.service...(..))"></aop:pointcut>
    <aop:advisor advice-ref="事务增强处理id" pointcut-ref="pc"></aop:advisor>
    </aop:config>
    练注解方式声明式事务
    提示:开启注解后 直接在service方法上写注解 或在类上写注解 优先使用方法上注解
    增删改@Transactional(propagation = Propagation.REQUIRED,readOnly = false,isolation = Isolation.REPEATABLE_READ)
    查@Transactional(propagation = Propagation.SUPPORTS,readOnly = true,isolation = Isolation.DEFAULT)

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

  • 相关阅读:
    centos/7下安装mysql5.7
    ubuntu下用vagrant搭建集群环境
    ubuntu下pyspark的安装
    Ubuntu下teamviewer的安装
    volatile(一)
    synchronized(九)
    synchronized(八)
    synchronized(七)
    synchronized(六)
    synchronized(五)
  • 原文地址:https://www.cnblogs.com/x-i-n/p/14151562.html
Copyright © 2011-2022 走看看