AOP

需要在业务系统中自定义AOP进行拦截相关资源:
定义advice逻辑(这里只用到了around):

@Slf4j
@Aspect
@Component
public class SomeAspect {

    @Around("execution(public * com.github.dreamroute.aop.service..*.*(..))")
    public Object process(ProceedingJoinPoint point) throws Throwable {
        System.out.println("before..."); // 之前的逻辑
        Object[] args = point.getArgs(); // 目标方法的参数,可以对参数进行修改
        Object result = point.proceed(args); // 原始逻辑
        System.out.println("before..."); // 之后的逻辑
        Object target = point.getTarget(); // 原始对象
        return result;
    }
}
原文地址:https://www.cnblogs.com/dreamroute/p/13845353.html