使用AOP切面的环绕通知,接口没有返回值

package com.dj.springboot.study.aware;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

/**
 * @Author: ldj
 * @Date: 2023/10/17/17:54
 * @Description:
 */
@Slf4j
@Aspect
@Component
public class TestAspect {

    @Around("@annotation(com.dj.springboot.study.annotation.RolePermission)")
    public Object doSth(ProceedingJoinPoint joinPoint) throws Throwable {
        System.out.println("前置处理");
        //执行目标原来方法
        Object result = joinPoint.proceed();
        System.out.println("后置处理");
        //一点要记得返回处理的结果,要不然接口没有响应数据
        return result;
    }
}

你可能感兴趣的:(java,spring,spring,boot)