<?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"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans.xsd
       http://www.springframework.org/schema/aop
       https://www.springframework.org/schema/aop/spring-aop.xsd
       http://www.springframework.org/schema/context
       https://www.springframework.org/schema/context/spring-context.xsd
    ">

    <import resource="classpath:transaction_aop.xml"></import>

<!--       1、配置目标对象 2、配置切面对象 3、配置织入告诉Spring 哪些方法（切点）需要增强 -->
    <bean id="target" class="com.aop.TargetImpl"></bean>
    <bean id="myaspect" class="com.aop.MyAspect">
    </bean>
    <aop:config>
        <!-- 声明切面-->
        <aop:aspect ref="myaspect">
            <!-- 切点 +通知 前置 后置 -->
<!--            <aop:before method="myBefore"-->
<!--                        pointcut="execution(void com.aop.TargetImpl.*())"-->
<!--            />-->
<!--            <aop:after method="after"-->
<!--                        pointcut="execution(public void com.aop.TargetImpl.save())"-->
<!--            />-->
            <aop:pointcut id="save2" expression="execution(public void com.aop.TargetImpl.save2())"/>
            <aop:around method="around" pointcut-ref="save2" />
            <aop:after-throwing method="afterThrowing"  pointcut-ref="save2" />
            <aop:after method="after" pointcut-ref="save2" />
        </aop:aspect>
    </aop:config>
    <context:component-scan base-package="com"></context:component-scan>
<!--    aop自动代理-->
    <aop:aspectj-autoproxy />
</beans>