Spring框架的AOP技术之通知类型

1. 通知类型
    * @Before               -- 前置通知
    * @AfterReturing        -- 后置通知
    * @Around               -- 环绕通知(目标对象方法默认不执行的,需要手动执行)
    * @After                -- 最终通知
    * @AfterThrowing        -- 异常抛出通知

2. 配置通用的切入点
    * 使用@Pointcut定义通用的切入点

    @Aspect
    public class MyAspectAnno {
        @Before(value="MyAspectAnno.fn()")
        public void log(){
            System.out.println("记录日志...");
        }
        @Pointcut(value="execution(public void com.huida.demo1.CustomerDaoImpl.save())")
        public void fn(){}
    }

猜你喜欢

转载自www.cnblogs.com/wyhluckdog/p/10133401.html