zoukankan      html  css  js  c++  java
  • 使用aop处理日志

    1.在springMvc的xml配置文件中加入开启aop和扫描aop的配置

        <!-- 将类加入IOC容器 -->
        <context:component-scan base-package="com.huqi.aop"></context:component-scan>
        <!-- 开启aop注解 -->
        <aop:aspectj-autoproxy/>

     2.编写aop类

    @Aspect
    @Configuration
    public class Logger {
        @Pointcut("@within(org.springframework.stereotype.Controller) || @within(org.springframework.web.bind.annotation.RestController)")
        public void cutController() {
        }
    
        @Around("cutController()")
        public Object recordSysLog(ProceedingJoinPoint joinPoint) throws Throwable {
            try {
    
                ob = joinPoint.proceed();
    
            } catch (Throwable throwable) {
              //此处一定要抛出异常
                throw throwable;
            } finally {
            
                
    
            }
    
            return ob;
        }
    
    }
  • 相关阅读:
    linux笔记
    ui转化为py
    stl学习
    React第一课
    React 第一课
    创建一个类
    nodejs基本语法
    let和const
    qml_status笔记
    controller层的单元测试
  • 原文地址:https://www.cnblogs.com/huqi96/p/13024837.html
Copyright © 2011-2022 走看看