xml方式实现:
注解实现:
切面:
@Component("myAspect")
@Aspect
public class MyAspect {
@Pointcut("execution(* com.it.aop.*.*(..))") //*为通配符 (..)表示任意参数
public void pointcut(){};
@Before("pointcut()")
public void before(){
System.out.println("before strength");
}
@Around("MyAspect.pointcut()")
public void around(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
System.out.println("环绕前");
proceedingJoinPoint.proceed();
System.out.println("环绕后");
}
}
需要在xml中配置注解驱动



