package com.wzy.aspect;import org.aspectj.lang.ProceedingJoinPoint;import org.aspectj.lang.annotation.*;import org.springframework.stereotype.Component;//增强的类@Component@Aspectpublic class UserProxy { //抽取公共部分 @Pointcut(value = "execution(* com.wzy.aspect.User.user(..))") public void pointdemo() { } //前置通知 //@Before 注解表示作为前置通知 @Before(value = "pointdemo()") public void before() { System.out.println("1、before........."); } //后置通知(返回通知) @AfterReturning(value = "pointdemo()") public void afterReturning() { System.out.println("2、afterReturning.........在方法返回值后执行"); } //最终通知 @After(value = "pointdemo()") public void after() { System.out.println("3、after.........在方法后执行"); } //异常通知 @AfterThrowing(value = "pointdemo()") public void afterThrowing() { System.out.println("4、afterThrowing........."); } //环绕通知 @Around(value = "pointdemo()") public void around(ProceedingJoinPoint proceedingJoinPoint) throws Throwable { System.out.println("环绕之前........."); //被增强的方法执行 Object proceed = proceedingJoinPoint.proceed(); System.out.println("环绕之后........."); }}