网站制作 流程购物返利网站怎么做

张小明 2026/1/10 1:49:30
网站制作 流程,购物返利网站怎么做,网站建设内部因素,网页设计大赛网站开发AOP 什么是AOP? 不影响原来的业务实现动态增加 AOP#xff08;Aspect Oriented Programming#xff09;意味#xff1a;切面编程#xff0c;通过预编译方式和运行期动态代理实现程序功能的同意维护的一种技术。AOP是OOP的延续#xff0c;是软件开发的热点#xff0c;也是…AOP什么是AOP?不影响原来的业务实现动态增加AOPAspect Oriented Programming意味切面编程通过预编译方式和运行期动态代理实现程序功能的同意维护的一种技术。AOP是OOP的延续是软件开发的热点也是Spring框架中的一个重要内容是函数式编程的一种衍生范型。利用AOP可以对可以对业务逻辑的各个部分进行隔离从而使得业务逻辑各部分之间耦合度降低提高程序的可重用性同时提高了开发的效率。Aop在Spring中的作用提供声明式事务允许用户自定义切面横切关注点跨越应用程序多个模块的方法或功能。即使与我们业务逻辑无关的但是我们需要关注的部分就是横切关注点。如日志、安全、缓存、事务等等……* 老外的名词很绕换一种方法了解切面ASPECT横切关注点 被模块化 的特殊对象。即它是一个类Log通知Advice切面必须要完成的工作。即它是类中的一个方法。Log中的方法目标Target被通知对象。 接口代理Proxy向目标对象应用通知之后创建的对象。 代理类切入点Point Cut切面通知执行的地点的定义连接点Joint Point与切入点匹配的执行点。SpringAop中通过Advice定义横切逻辑Spring中支持五种类型的AdviceAop在不改变原有代码的情况下去增加新的功能。使用Spring实现Aop【重点】使用AOP织入需要导入一个依赖包叫做织入包!-- https://mvnrepository.com/artifact/org.aspectj/aspectjweaver --dependencygroupIdorg.aspectj/groupIdartifactIdaspectjweaver/artifactIdversion1.9.4/version/dependency方式一使用Spring的Api接口配置AOP的约束?xml version1.0 encodingUTF-8?beansxmlnshttp://www.springframework.org/schema/beansxmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexmlns:contexthttp://www.springframework.org/schema/contextxmlns:aophttp://www.springframework.org/schema/aopxsi:schemaLocationhttp://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/aop https://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsdcontext:annotation-config/context:component-scanbase-packagecom.cike9//beans配置bean容器idbeanidlogclasscom.cike9.log.Log/beanidafterLogclasscom.cike9.log.AfterLog/beaniduserServiceImplclasscom.cike9.service.UserServiceImpl/Spring AOP 的 XML 配置方式aop:config!--切入点--aop:pointcutidpointcutexpressionexecution(* com.cike9.service.UserServiceImpl.*(..))/!--执行环绕增加--aop:advisoradvice-reflogpointcut-refpointcut/aop:advisoradvice-refafterLogpointcut-refpointcut//aop:configexecution(返回值类型 包名.类名/接口名.方法名(任意的参数列表))(…)可以代表所有参数,()代表一个参数,(,String)代表第一个参数为任何值,第二个参数为String类型.整体代码业务类的接口 (UserService)publicinterfaceUserService{voidadd();voiddelete();voidupdate();voidquery();}实际业务类UserServiceImpl)publicclassUserServiceImplimplementsUserService{Overridepublicvoidadd(){System.out.println(增加了一个用户);}Overridepublicvoiddelete(){System.out.println(删除了一个用户);}Overridepublicvoidupdate(){System.out.println(更新用户);}Overridepublicvoidquery(){System.out.println(查询用户);}}横向扩展业务类AfterLogpublicclassAfterLogimplementsAfterReturningAdvice{// 返回值方法参数目标对象publicvoidafterReturning(ObjectreturnValue,Methodmethod,Object[]args,Objecttarget)throwsThrowable{System.out.println(执行了method.getName()方法返回第结果为returnValue);}}横向扩展业务类 LogpublicclassLogimplementsMethodBeforeAdvice{// method:要执行的目标对象的方法// Objects参数// 他target 目标对象publicvoidbefore(Methodmethod,Object[]args,Objecttarget)throwsThrowable{System.out.println(target.getClass().getName()的method.getName()方法被执行了);}}Spring的XML配置applicationContext.xml)?xml version1.0 encodingUTF-8?beansxmlnshttp://www.springframework.org/schema/beansxmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexmlns:contexthttp://www.springframework.org/schema/contextxmlns:aophttp://www.springframework.org/schema/aopxsi:schemaLocationhttp://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/aop https://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsdcontext:annotation-config/context:component-scanbase-packagecom.cike9/beanidlogclasscom.cike9.log.Log/beanidafterLogclasscom.cike9.log.AfterLog/beaniduserServiceImplclasscom.cike9.service.UserServiceImpl/!-- 方式一使用原生Spring API接口 配置aop需要导入aop的约束 --aop:config!--切入点--aop:pointcutidpointcutexpressionexecution(* com.cike9.service.UserServiceImpl.*(..))/!--执行环绕增加--aop:advisoradvice-reflogpointcut-refpointcut/aop:advisoradvice-refafterLogpointcut-refpointcut//aop:config/beans测试类publicclassspring09_Test{Testpublicvoidtest(){ApplicationContextcontextnewClassPathXmlApplicationContext(applicationContext.xml);// 动态代理的是接口不应该写实现类这里UserServiceuserServiceImpl(UserService)context.getBean(userServiceImpl);userServiceImpl.add();}}可以发现扩展业务类市集上调用的就是这两种实现接口都是通知类型通过这种方式可以找到aop下可以用的接口方法方式二自定义类实现AOP【主要是切面定义】自定义类packagecom.cike9.diy;publicclassDiyPointCut{voidbefore(){System.out.println(方法执行前);}voidafter(){System.out.println(方法执行后);}}applicationContext.xml?xml version1.0 encodingUTF-8?beansxmlnshttp://www.springframework.org/schema/beansxmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexmlns:contexthttp://www.springframework.org/schema/contextxmlns:aophttp://www.springframework.org/schema/aopxsi:schemaLocationhttp://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/aop https://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsdcontext:annotation-config/context:component-scanbase-packagecom.cike9/beanidlogclasscom.cike9.log.Log/beanidafterLogclasscom.cike9.log.AfterLog/beaniduserServiceImplclasscom.cike9.service.UserServiceImpl/!--方式二自定义类--beaniddiyclasscom.cike9.diy.DiyPointCut/aop:config!--自定义切面--aop:aspectrefdiy!--切入点--aop:pointcutidpointexpressionexecution(* com.cike9.service.UserServiceImpl.*(..))/!--通知 --aop:beforemethodbeforepointcut-refpoint/!--在切入点之前执行通知--aop:aftermethodafterpointcut-refpoint//aop:aspect/aop:config/beans业务接口publicinterfaceUserService{voidadd();voiddelete();voidupdate();voidquery();}业务实现类publicclassUserServiceImplimplementsUserService{Overridepublicvoidadd(){System.out.println(增加了一个用户);}Overridepublicvoiddelete(){System.out.println(删除了一个用户);}Overridepublicvoidupdate(){System.out.println(更新用户);}Overridepublicvoidquery(){System.out.println(查询用户);}}测试类publicclassspring09_Test{Testpublicvoidtest(){ApplicationContextcontextnewClassPathXmlApplicationContext(applicationContext.xml);// 动态代理的是接口不应该写实现类这里UserServiceuserServiceImpl(UserService)context.getBean(userServiceImpl);userServiceImpl.add();}}方式三使用注解实现在自定义类里面添加注解开启直接支持aop:aspectj-autoproxy/切面 Aspect切入点 Before(“execution(* com.cike9.service.UserServiceImpl.*(…))”)自定义类中进行注解开发AOPComponent(annotationPointCut)// 使用注解方式实现AOPAspect// 标注这个类是一个切面 相当于aop:configaop:aspect refdiy/aop:configpublicclassAnnotationPointCut{// 这里相当于切入点Before(execution(* com.cike9.service.UserServiceImpl.*(..)))voidbefore(){//通知的方法System.out.println(方法执行前);}After(execution(* com.cike9.service.UserServiceImpl.*(..)))voidafter(){System.out.println(方法执行后);}}applicattionContext.xml?xml version1.0 encodingUTF-8?beansxmlnshttp://www.springframework.org/schema/beansxmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexmlns:contexthttp://www.springframework.org/schema/contextxmlns:aophttp://www.springframework.org/schema/aopxsi:schemaLocationhttp://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/aop https://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsdcontext:annotation-config/context:component-scanbase-packagecom.cike9/!--方式三开启注解支持 JDK默认 proxy-target-classfalse cgilibproxy-target-classtrue)--aop:aspectj-autoproxyproxy-target-classfalse//beans业务实现类importorg.springframework.stereotype.Service;Service(userServiceImpl)// 相当于bean配置 bean iduserServiceImpl classcom.cike9.service.UserServiceImpl/publicclassUserServiceImplimplementsUserService{Overridepublicvoidadd(){System.out.println(增加了一个用户);}Overridepublicvoiddelete(){System.out.println(删除了一个用户);}Overridepublicvoidupdate(){System.out.println(更新用户);}Overridepublicvoidquery(){System.out.println(查询用户);}}业务接口publicinterfaceUserService{voidadd();voiddelete();voidupdate();voidquery();}测试publicclassspring09_Test{Testpublicvoidtest(){ApplicationContextcontextnewClassPathXmlApplicationContext(applicationContext.xml);// 动态代理的是接口不应该写实现类这里UserServiceuserServiceImpl(UserService)context.getBean(userServiceImpl);userServiceImpl.add();}}
版权声明:本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!

苏州网站建设建网站html网页设计网站

如何选择最适合你的智能图像标注工具?GPT4V-Image-Captioner终极指南 【免费下载链接】GPT4V-Image-Captioner 项目地址: https://gitcode.com/gh_mirrors/gp/GPT4V-Image-Captioner 在当今信息爆炸的时代,图像内容的处理和分析已成为许多行业不…

张小明 2026/1/8 8:03:22 网站建设

重庆网站设计排名敦化市住房和城乡建设局网站

GPT-SoVITS语音合成与金融级安全实践:如何满足等保三级要求 在银行App里听到自己的声音播报余额变动,是一种什么样的体验?这不是科幻电影桥段,而是正在部分金融机构试点落地的真实场景。借助GPT-SoVITS这类少样本语音克隆技术&…

张小明 2026/1/8 8:11:46 网站建设

网站网站开发设计关键词seo优化

Minecraft 1.21 Masa模组中文汉化包:5分钟快速安装完整中文界面指南 【免费下载链接】masa-mods-chinese 一个masa mods的汉化资源包 项目地址: https://gitcode.com/gh_mirrors/ma/masa-mods-chinese 还在为看不懂Masa模组的英文界面而烦恼吗?Ma…

张小明 2026/1/9 22:33:52 网站建设

长沙h5建站上海企业网络推广价格

目录具体实现截图项目介绍论文大纲核心代码部分展示可定制开发之亮点部门介绍结论源码获取详细视频演示 :文章底部获取博主联系方式!同行可合作具体实现截图 本系统(程序源码数据库调试部署讲解)同时还支持Python(flask,django)、…

张小明 2026/1/8 14:56:05 网站建设

水墨风格网站欣赏深圳住房与城乡建设部网站

绵阳口腔医院的技术探索与科雅口腔的专业实践绵阳口腔医院在发展过程中面临着一些技术挑战,如治疗精度不够、患者体验有待提升等。绵阳科雅口腔门诊部针对这些问题提供了专业解决方案。科雅口腔采用先进的数字化口腔技术,通过口腔扫描仪获取患者口腔的精…

张小明 2026/1/8 2:15:51 网站建设

网站备案格式郯城做网站

多风格视频生成技术深度解析:HunyuanVideo的10个核心突破与实战指南 【免费下载链接】HunyuanVideo HunyuanVideo: A Systematic Framework For Large Video Generation Model Training 项目地址: https://ai.gitcode.com/tencent_hunyuan/HunyuanVideo 在数…

张小明 2026/1/6 6:16:02 网站建设