自定义AOP对注解进行拦截

145 阅读1分钟
@Slf4j
@Aspect
@Component
public class MVCAspectJComponent {

    @Pointcut("@within(org.springframework.web.bind.annotation.RestController) " +
            "|| @within(org.springframework.stereotype.Controller)")
    public void postCut(){}

    @Around("postCut()")
    public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
        log.info("MVCAspectJComponent#around before");
        Object object = joinPoint.proceed();
        log.info("MVCAspectJComponent#around after");
        return object;
    }
}