<!--切点-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
@Aspect
@Component
@Slf4j
public class LogPoint {
@Pointcut("execution(public * com.system.dataplatform.controller.*.*(..))")
public void soutLog(){};
@Before("soutLog()")
public void doBefore(JoinPoint joinPoint) throws Throwable{
//打印调用的方法
Signature signature = joinPoint.getSignature();
String methodName = signature.getName();
log.info("==============调用方法"+methodName+",位置:"+joinPoint.getSignature().toString());
//打印调用方法时传入的参数
String[] paramNames = ((CodeSignature) signature).getParameterNames();
Object[] paramValues = joinPoint.getArgs();
for (int i = 0; i < paramNames.length; i++) {
log.info("==============打印调用"+methodName+"方法传入的参数=" + paramNames[i] + ":" + paramValues[i]);
}
}
}