美文网首页
spring aop环绕通知

spring aop环绕通知

作者: simplerandom | 来源:发表于2020-07-24 10:08 被阅读0次
    <bean id="hello" class="org.spring.Hello"></bean>
        <bean id="log" class="org.spring.Log"></bean>
        <aop:config>
            <aop:aspect id="log" ref="log">
                <aop:pointcut id="pt" expression="execution(public void org.spring.Hello.aop())"></aop:pointcut>
                <aop:around method="around" pointcut-ref="pt"></aop:around>
            </aop:aspect>
        </aop:config>
    
     public Object around(ProceedingJoinPoint joinPoint){
            Object[] args = joinPoint.getArgs();
            Object proceed = null;
            try {
                System.out.println("around前置通知");
                proceed = joinPoint.proceed(args);
                System.out.println("后置");
            } catch (Throwable throwable) {
                System.out.println("异常");
                throwable.printStackTrace();
            }finally {
                System.out.println("最终");
            }
            return proceed;
        }
    

    相关文章

      网友评论

          本文标题:spring aop环绕通知

          本文链接:https://www.haomeiwen.com/subject/tbtjlktx.html