首页 > 编程知识 正文

stringbuffer stringbuilder,mybatisxml标签

时间:2023-05-04 09:54:06 阅读:110081 作者:864

package com.itheima.jdk; 公共语音地址{公共语音(; 公共语音删除器(; } package com.itheima.jdk; importorg.spring framework.stereotype.repository; //目标类@repository(userdao ) (publicclassuserdaoimplimplementsuserdao ) (publicvoidadduser ) {//int i=10/0; System.out.println (“添加用户”); } public void deleteuser ((system.out.println ) )“删除用户”; } package com.it heima.AspectJ.XML; importorg.AspectJ.lang.join point; importorg.AspectJ.lang.proceeding join point; importorg.AspectJ.lang.annotation.after; importorg.AspectJ.lang.annotation.after returning; importorg.AspectJ.lang.annotation.after throwing; importorg.AspectJ.lang.annotation.around; importorg.AspectJ.lang.annotation.aspect; importorg.AspectJ.lang.annotation.before; importorg.AspectJ.lang.annotation.pointcut; importorg.spring framework.stereotype.com ponent; /**切面类,通知此类*/@ aspect @ componentpublicclassmyaspect { /定义切口表达式@pointcut(execution ) com.itheima.JDK.*.*。 切入点private void myPointCut () }/提前通知@ before (before ) (mypointcut ) ) publicvoidmybefore(joinpoint ) ) systant system . System.out.println (,嵌入增强处理的目标方法是(joinPoint.getSignature ) ).getName ) ); ///后置通知@ after returning (value=' my pointcut () ) (publicvoidmyafterreturning ) jointjoinpoint ) { system.out.print } //环绕声通知:总是接收ProceedingJoinPoint类型的参数,返回类型为Object,并抛出异常。 @around(mypointcut ) ) ) publicobjectmyaround ) proceedingjoinpointproceedingjoinpoint ) throws Throwable {//到system //退出System.out.println ('包装结束:执行目标方法后关闭事务的模拟.'); 返回对象; //异常通知:可以传递Throwable类型参数以打印异常信息@ after throwing (value=' my pointcut ),throwing='e ' ) publicvoidmyafterthrowing publicvoidmyafterowi //最终通知@after(mypointcut ) ) (public void myAfter ) ) {System.out.println ) )最终通知:模拟方法结束后的资源}? XML版本=' 1.0 '编码=' utf-8 '? beans xmlns=' http://www.spring framework.org/schema/beans ' xmlns 3360 xsi=' http://www.w3.org/2001/XML方案-实例' xmlns : AOP=' http://www.spring framework.org/schema/AOP ' xsi :方案位置=' 3358 ww bw beans/spring-beans-4.3.xsd 3358 www.spring framework.org/schema/schema-1目标类--bean id=' userdao ' class -2切面--bean id=' my aspect ' class=' com.it heima.AspectJ.XML.my aspect ' /! -- 3 aop编程--aop:config! -放置切割平面--aop:aspect ref='myAspect '! -- 3.1构成最终通知加强哪些方法的切入点--AOP : pointcut expression=' execution (com.it heima.JDK.*.*.* () id=' ) -- 3.2.1提前通知--- AOP : before method=' my before ' pointcut-ref=' my pointcut ' /! -- 3.2.2职位通知。 方法返回后执行时,将检索返回值的returning属性。 用于设置后通知的第二个参数的名称。 类型为object-- AOP : after-returning method=' myafterreturning ' ppaper--3.2. 3周通知--AOP : around method='。 -- 3.2.4发布通知:处理程序发生异常时- -! -*注意:如果程序没有异常,则不执行---! -- * throwing属性:用于设置通知中第二个参数的名称。 类型throwable-- AOP : after-throwing method=' myafterthrowing ' pointcut-ref=' mypointcunt--3.2. 5最终通知:程序需要什么tcut-ref=' my pointcut '/AOP 3360 aspect/AOP 3360 importorg.spring framework.context.application context; importorg.spring framework.context.support.classpathxmlapplicationcontext; import com.itheima.jdk.UserDao; //测试类publicclasstestxmlaspectj (publicstaticvoidmain (string args [ ] ) string XML path=' com/it heima/AspectJ/XML/AspectJ applicationcontextapplicationcontext=newclasspathxmlapplicationcontext (XML path ); //1spring容器中的内容userdaouserdao=(userdao ) application context.get bean (userdao ); //2如何执行userDao.addUser (); }

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。