<- 依赖 !->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
/**
*
*/
package com.icil.esolution.aspect;
import java.util.Date;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
/**
*
*@ClassName: TimeAspect
*
* @Description:
*
* @Author: Sea
*
* @Date: 16 Oct 2018 7:18:40 PM
*/
@Aspect
@Component
public class TimeAspect {
private static Logger logger =LoggerFactory.getLogger(TimeAspect.class);
// @Around("execution(* com.sea.web.controller.UserController.*(..))")
@Around("execution(* com.sea.haha.controller.*.*(..))")
public Object handleControllerMethod(ProceedingJoinPoint pjp) throws Throwable {
long start = System.currentTimeMillis();
Object object = pjp.proceed();
String costTime = (System.currentTimeMillis() - start) + "";
Object[] args = pjp.getArgs();
String methodName = pjp.getSignature().getName();
logger.info("*************** Run the method --> {} params : {} total cost time is {} ms********************",methodName,args,costTime);
return object;
}
}