Day13-09.AOP进阶-切入点表达式-@annotation
1.切入点表达式-@annotation
1.@annotation 切入点表达式,用于匹配标识有特定注解的方法。
@annotation(com.itheima.anno.Log)
@Before("annotation(com.itheima.anno.Log)")
public void before(){
log.info("before...");
}
@Slf4j
@Component
@Aspect
public class MyAspect6 {
//@Pointcut("execution(public void com.itheima.service.impl.DeptServiceImpl.add(*))")
//@Pointcut("execution(public void com.itheima.service.impl.DeptServiceImpl.add(com.itheima.pojo.Dept)))")
//@Pointcut("execution(public void com.itheima.service.impl.*Impl.add*(com.itheima.pojo.Dept)))")
//@Pointcut("execution(public void com.itheima.service.impl.*Impl.add*(..)))")
//@Pointcut("execution(* com.itheima.service.DeptService.list())||" + "execution(* com.itheima.service.DeptService.delete(java.lang.Integer))")
@Pointcut("@annotation(com.itheima.aop.MyLog)")
public void pt() {
}
@Before("pt()")
public void before() {
log.info("MyAspect6...before");
}
}
2.小结:
1.execution(修饰符? 返回值 包名.类名.?方法名(参数) throws 异常?)
2.@annotation(注解全类名)