标签:imp npoi around etc pack ram col 案例 service
package com.jt.aop;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;
@Component
@Aspect
public class ExecutionAop {
//如果程序出现了异常,则需要拦截,打印异常信息
@AfterThrowing
(pointcut = "execution(* com.jt.service..*.*(..))",
throwing = "throwable")
public void afterThrow(JoinPoint joinPoint,Throwable throwable) {
Class<?> targetClass = joinPoint.getTarget().getClass();
String methodName = joinPoint.getSignature().getName();
Class<?> throwClass = throwable.getClass();
String msg = throwable.getMessage();
System.out.println("目标对象类型:"+targetClass);
System.out.println("目标方法:"+methodName);
System.out.println("异常类型:"+throwClass);
System.out.println("异常信息:"+msg);
}
}
标签:imp npoi around etc pack ram col 案例 service
原文地址:https://www.cnblogs.com/lizhiwei666/p/12037276.html