执行顺序:
前置增强---->目标函数----->后置增强------>返回增强/异常增强
注意:
@Before、@After、@AfterRunning和@AfterThrowing修饰的方法没有返回值;而@Around修饰的方法必须有返回值
@Aspect
public class Log {
@Before("execution(* com.AOPAnnotation.service.UserServiceImpl.*(..))")
public void before() {
System.out.println("执行前");
}
@After("execution(* com.AOPAnnotation.service.UserServiceImpl.*(..))")
public void after() {
System.out.println("执行后");
}
@Around("execution(* com.AOPAnnotation.service.UserServiceImpl.*(..))")
public void Around(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
System.out.println("环绕前");
proceedingJoinPoint.proceed();
System.out.println("环绕后");
}
}