devil5263 2015-05-25 16:15 采纳率: 0%
浏览 1885

LogAfterReturningAdvice层次结构不一致

package com.aop.spring;
import java.lang.reflect.Method;
import java.text.DateFormat;
import java.util.Date;
import org.springframework.aop.AfterReturningAdvice;

public class LogAfterReturningAdvice implements AfterReturningAdvice{
public void afterReturning(Object returnValue,Method targetMethod,Object[] methodArgs,
Object targetClass)throws Throwable{
boolean success=((Boolean)returnValue).booleanValue();
if(success){
String className=targetClass.getClass().getName();
String methodName=targetMethod.getName();
Date date=new Date();
String curTime=DateFormat.getDateTimeInstance().format(date);
String logInfo="["+curTime+"]:"+className+"."+methodName+"()方法被调用!";
System.out.println(logInfo);
}

}

}

  • 写回答

1条回答

  • qq_28486429 2015-05-25 17:31
    关注

    LogAfterReturningAdvice层次结构不一致
    java-aop
    package com.aop.spring;
    import java.lang.reflect.Method;
    import java.text.DateFormat;
    import java.util.Date;
    import org.springframework.aop.AfterReturningAdvice;
    public class LogAfterReturningAdvice implements AfterReturningAdvice{
    public void afterReturning(Object returnValue,Method targetMethod,Object[] methodArgs,
    Object targetClass)throws Throwable{
    boolean success=((Boolean)returnValue).booleanValue();
    if(success){
    String className=targetClass.getClass().getName();
    String methodName=targetMethod.getName();
    Date date=new Date();
    String curTime=DateFormat.getDateTimeInstance().format(date);
    String logInfo="["+curTime+"]:"+className+"."+methodName+"()方法被调用!";
    System.out.println(logInfo);
    }
    }
    }

    评论

报告相同问题?

悬赏问题

  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料