<!--springIoc注解自动扫描:-->
<context:component-scan base-package="com.cn" />
<!--aop注解自动扫描-->
<aop:aspectj-autoproxy ></aop:aspectj-autoproxy>
<!--开启事务注释驱动 transaction-manager事务管理器-->
<tx:annotation-driven transaction-manager="transactionManager"/>
<!--springAop基于xml:-->
<!-- proxy-target-class="false" 是否用JDK动态代理,true使用的是cglib -->
<aop:config proxy-target-class="false">
<aop:pointcut id="pcut" expression="execution(* com.yfs1024.service.*.*(..) )" />
<!-- 配置切面 -->
<aop:aspect id="logger" ref="logger">
<!-- 前置通知 -->
<aop:before method="beforeMethod" pointcut-ref="pcut"/>
<!-- 后置通知 -->
<aop:after-returning method="afterMethod" pointcut-ref="pcut"/>
</aop:aspect>
</aop:config>
<!--通知的定义:-->
<!--定义通知-->
<tx:advice id="interceptor" transaction-manager="transactionManager">
<tx:attributes>
<!--name,表示添加事务的方法 可以有多个 method方法名 isolation:隔离级别 read-only:只读 propagation:传播行为-->
<tx:method name="buy" isolation="DEFAULT" read-only="false" propagation="REQUIRED"
rollback-for="java.lang.NullPointerException,com.yfs1024.exception.MyselfException"/>
<tx:method name="*update" />
<tx:method name="*delete" />
</tx:attributes>
</tx:advice>
<!--配置aop-->
<aop:config>
<!--简单举例比如service下的-->
<aop:pointcut id="sevicepointcut" expression="execution(* *..service..*.*(..))"/>
<!--配置增强器关联advice和pointcut-->
<aop:advisor advice-ref="interceptor" pointcut-ref="sevicepointcut"/>
</aop:config>