package tju.SpringBootAop.aspect;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.DeclareParents;
import org.aspectj.lang.annotation.Pointcut;
import tju.SpringBootAop.validator.UserValidator;
import tju.SpringBootAop.validator.impl.UserValidatorImpl;
@Aspect
public class MyAspect2 {
@DeclareParents(value="tju.SpringBootAop.service.impl.UserServiceImpl+",
defaultImpl=UserValidatorImpl.class)
public UserValidator userValidator;
@Pointcut("execution( * tju.SpringBootAop.service.*.*(..))")
public void myPointcut(){}
@Before("myPointcut()")
public void log()
{
System.out.println("before operation2 ....");
}
}
要求SpringBoot版本为2.2.0及以上