Spring中的AOP和属性注入

下来先说 前置和后置增强  

1 前置增强  需要一个类 实现 

implements MethodBeforeAdvice 以下接口 ,并且实现接口中的方法 
public class lasraop implements MethodBeforeAdvice {
    public void before(Method method, Object[] objects, Object o) throws Throwable {
        System.out.println("bengin");
    }
}

2 后置增强  需要一个类 实现

implements AfterReturningAdvice
以下接口 ,并且实现接口中的方法  

public class fristaop implements AfterReturningAdvice {
    public void afterReturning(Object o, Method method, Object[] objects, Object o1) throws Throwable {

        System.out.println("日志记录");
    }
}

配置
<bean id="first" class="cn.study.aop.fristaop"></bean>

    <bean id="last" class="cn.study.aop.lasraop"></bean>





 
posted @ 2018-03-06 21:50  我不是.好人  阅读(340)  评论(0编辑  收藏  举报