springboot最简单的AOP
package com.yitiantec.ecommerce.admin.config;
import java.lang.reflect.Method;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.context.annotation.Configuration;
import com.yitiantec.ecommerce.admin.util.XinyuanJSONUtil;
import lombok.extern.slf4j.Slf4j;
@Aspect //一个切面
@Configuration // spring boot 配置类
@Slf4j
public class RequestParamValidAspect {
@Pointcut("execution(* com.yitiantec.demo.pay.controller.*.*(..))")
public void soaServiceBefore(){}
/* * 通过连接点切入 */
@Before("soaServiceBefore()")
public void twiceAsOld1(JoinPoint point) {
// 获得切入目标对象
Object target = point.getThis();
// 获得切入方法参数
Object [] args = point.getArgs();
// 获得切入的方法
Method method = ((MethodSignature)point.getSignature()).getMethod();
log.info("AOP 进入方法"+method);
log.info("APO 收到参数="+XinyuanJSONUtil.gSonString(args));
}
}