news 2026/4/18 4:01:05

(38)基于XML配置方式的AOP(了解)

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
(38)基于XML配置方式的AOP(了解)

第一步:编写目标类

packagecom.powernode.spring6.service;// 目标类publicclassVipService{publicvoidadd(){System.out.println("保存vip信息。");}}

第二步:编写切面类,并且编写通知

packagecom.powernode.spring6.service;importorg.aspectj.lang.ProceedingJoinPoint;// 负责计时的切面类publicclassTimerAspect{publicvoidtime(ProceedingJoinPointproceedingJoinPoint)throwsThrowable{longbegin=System.currentTimeMillis();//执行目标proceedingJoinPoint.proceed();longend=System.currentTimeMillis();System.out.println("耗时"+(end-begin)+"毫秒");}}

第三步:编写spring配置文件

<?xml version="1.0" encoding="UTF-8"?><beansxmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:context="http://www.springframework.org/schema/context"xmlns:aop="http://www.springframework.org/schema/aop"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"><!--纳入spring bean管理--><beanid="vipService"class="com.powernode.spring6.service.VipService"/><beanid="timerAspect"class="com.powernode.spring6.service.TimerAspect"/><!--aop配置--><aop:config><!--切点表达式--><aop:pointcutid="p"expression="execution(* com.powernode.spring6.service.VipService.*(..))"/><!--切面--><aop:aspectref="timerAspect"><!--切面=通知 + 切点--><aop:aroundmethod="time"pointcut-ref="p"/></aop:aspect></aop:config></beans>

测试程序:

packagecom.powernode.spring6.test;importcom.powernode.spring6.service.VipService;importorg.junit.Test;importorg.springframework.context.ApplicationContext;importorg.springframework.context.support.ClassPathXmlApplicationContext;publicclassAOPTest3{@TestpublicvoidtestAOPXml(){ApplicationContextapplicationContext=newClassPathXmlApplicationContext("spring-aop-xml.xml");VipServicevipService=applicationContext.getBean("vipService",VipService.class);vipService.add();}}
版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/4/18 4:00:09

YOLO工业部署难点解析:从模型导出到GPU推理优化

YOLO工业部署难点解析&#xff1a;从模型导出到GPU推理优化 在现代智能制造产线中&#xff0c;视觉检测系统早已不再是“锦上添花”的辅助模块&#xff0c;而是决定良品率与自动化水平的核心环节。一条每分钟处理数百件产品的流水线上&#xff0c;留给目标检测算法的响应时间往…

作者头像 李华
网站建设 2026/4/16 19:06:29

ITU-T G.729 语音编解码器负载格式、传输机制与性能深度分析报告

ITU-T G.729 语音编解码器负载格式、传输机制与性能深度分析报告 1. 引言&#xff1a;G.729 标准的演进与技术定位 1.1 标准化背景与电信级压缩的需求 在数字语音通信的发展历程中&#xff0c;ITU-T G.729 标准的发布标志着一个重要的转折点。20世纪90年代中期&#xff0c;随…

作者头像 李华
网站建设 2026/4/17 19:55:06

YOLO模型训练支持Mixed Precision Training混合精度训练

YOLO模型训练支持Mixed Precision Training混合精度训练 在现代智能系统中&#xff0c;实时目标检测早已不再是实验室里的概念验证&#xff0c;而是广泛落地于工厂质检、城市监控、无人配送等真实场景的核心能力。随着这些应用对响应速度和部署成本的要求越来越高&#xff0c;如…

作者头像 李华
网站建设 2026/4/16 17:05:46

YOLO目标检测支持DDS(Data Distribution Service)

YOLO目标检测与DDS通信的融合架构 在现代工业自动化、智能交通和机器人系统的演进中&#xff0c;一个核心挑战始终存在&#xff1a;如何让机器“看得准”又“反应快”。视觉感知不再只是单点任务&#xff0c;而是分布式智能系统中的关键一环。当摄像头识别出障碍物时&#xff0…

作者头像 李华
网站建设 2026/4/18 2:18:58

混凝土多边形骨料二维建模:从构思到实现

混凝土多边形骨料二维建模&#xff0c;多边形的边数随机的&#xff0c;可改变骨料面积分数和界面国过渡区厚度&#xff0c;模型的大小也可改变&#xff0c;Comsol with Matlab生成的&#xff0c;得到.mph文件&#xff0c;Comsol直接可以打开&#xff0c;用于后续计算 app&#…

作者头像 李华
网站建设 2026/4/16 6:13:39

鸿蒙原生系列之动画效果(关键帧动画)

鸿蒙原生系列之关键帧动画〇、前言一、动画分类3、关键帧动画3.1、ArkUI_KeyframeAnimateOption3.2、动画时间与播放次数3.3、注册动画分段回调3.4、注册动画结束回调3.5、播放关键帧动画二、动画实现3、关键帧动画3.1、自定义按钮形状3.2、实现页面结构3.3、实现关键帧动画3.4…

作者头像 李华