加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

Spring AOP

发布时间:2020-12-15 01:11:24 所属栏目:大数据 来源:网络整理
导读:Spring-mybatis.xml aop:aspectj-autoproxy / LogAdvice.java @Aspect@Component public class LogAdvice { // 可复用的植入点,方法名method为引用 @Pointcut("execution(* com.ssm..*.transferMoneyByProcedure(..))" ) void method() {} @Before( "execut

Spring-mybatis.xml

<aop:aspectj-autoproxy />

LogAdvice.java

@Aspect
@Component
public class LogAdvice {

    //可复用的植入点,方法名method为引用
    @Pointcut("execution(* com.ssm..*.transferMoneyByProcedure(..))")
    void method() {}

    @Before("execution(public void com.ssm.dao.UserDao.transferMoney(*))" before(){
        System.err.println("Spring AOP  before method....");
    }

    @AfterReturning("method()" after() {
        System.err.println("Spring AOP  after method....");
    }

    @AfterThrowing("method()" exception() {
        System.err.println("Spring AOP  throws Exception....");
    }

    @Around("method()"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</artifactId>aspectjweaverversion>1.8.7>
>

?

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读