• Spring AOP


    Spring-mybatis.xml

    <aop:aspectj-autoproxy />

    LogAdvice.java

    @Aspect
    @Component
    public class LogAdvice {
    
        //可复用的植入点,方法名method为引用
        @Pointcut("execution(* com.ssm..*.transferMoneyByProcedure(..))")
        public void method() {}
    
        @Before("execution(public void com.ssm.dao.UserDao.transferMoney(*))")
        public void before(){
            System.err.println("Spring AOP  before method....");
        }
    
        @AfterReturning("method()")
        public void after() {
            System.err.println("Spring AOP  after method....");
        }
    
        @AfterThrowing("method()")
        public void exception() {
            System.err.println("Spring AOP  throws Exception....");
        }
    
        @Around("method()")
        public void around(ProceedingJoinPoint point) throws Throwable {
    
            System.err.println("String AOP around start....");
            point.proceed();
            System.err.println("String AOP around end....");
        }
    
    }

    pom.xml

    <dependency>
                <groupId>org.aspectj</groupId>
                <artifactId>aspectjweaver</artifactId>
                <version>1.8.7</version>
    </dependency>
  • 相关阅读:
    Linux命令大全
    Restframework 视图组件与序列号组件的应用.
    Linux常用命令
    数据结构
    MongoDB
    算法
    Flask 语音分析
    Flask Session ,pymysql ,wtforms组件 虚拟virtualenv venv
    Flask 视图,模板,蓝图.
    Flask初识
  • 原文地址:https://www.cnblogs.com/cocoat/p/4915436.html
Copyright © 2020-2023  润新知