当前位置: 首页 > news >正文

宜春做网站 黑酷seo推广网站哪个好

宜春做网站 黑酷seo,推广网站哪个好,图书馆建设投稿网站,网站推广效果分析Aspect(切面):用于标识一个类是切面的注解。通常与其他通知注解一起使用,定义切面类。 Pointcut(切点): 注解来定义切点,它用于描述哪些连接点将会被通知所通知。 连接点&#xff…

@Aspect(切面):用于标识一个类是切面的注解。通常与其他通知注解一起使用,定义切面类。

@Pointcut(切点): 注解来定义切点,它用于描述哪些连接点将会被通知所通知。

连接点:execution(* com.example.service.*.*(..))

通知类

  1. @Before:前置通知,在目标方法执行前执行。
  2. @Around:环绕通知,在目标方法执行前后都执行,并且可以控制是否执行目标方法。
  3. @AfterReturning:正常返回通知,目标方法正常返回后执行。
  4. @AfterThrowing:异常返回通知,在目标方法抛出异常后执行。
  5. @After:后置通知,在目标方法执行后执行,无论是否抛出异常都会执行。

执行顺序:

1、使用前置通知

  • 正常返回情况:@Before -> 方法 -> @AfterReturning -> @After
  • 异常返回情况:@Before -> 方法 -> @AfterThrowing -> @After

2、使用环绕通知

  • 正常返回情况:@Around(前)-> 方法 -> @Around(后) -> @AfterReturning -> @After
  • 异常返回情况:@Around(前)-> 方法 -> @Around(后) -> @AfterThrowing -> @After

3、前置通知和环绕通知都使用

  • 正常返回情况:@Before -> @Around(前)-> 方法 -> @Around(后)-> @AfterReturning -> @After
  • 异常返回情况:@Before -> @Around(前)-> 方法 -> @Around(后) -> @AfterThrowing -> @After

注意:在 @Around 通知类型中,通过调用 ProceedingJoinPoint.proceed() 才会触发目标方法的执行,因此可以在方法执行前后加入额外的逻辑。

实现AOP案例:

@Aspect
@Component
public class LoggingAspect {@Before("execution(* com.example.MyService.*(..))")public void beforeMethodExecution(JoinPoint joinPoint) {String methodName = joinPoint.getSignature().getName();System.out.println("Before executing method: " + methodName);}@Around("execution(* com.example.MyService.*(..))")public Object aroundMethodExecution(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {String methodName = proceedingJoinPoint.getSignature().getName();System.out.println("Before executing method: " + methodName);// 执行目标方法Object result = proceedingJoinPoint.proceed();System.out.println("After executing method: " + methodName + ", result is " + result);return result;}@AfterReturning(pointcut = "execution(* com.example.MyService.*(..))", returning = "result")public void afterMethodExecution(Object result) {System.out.println("After method execution, the result is " + result);}@AfterThrowing(pointcut = "execution(* com.example.MyService.*(..))", throwing = "e")public void afterMethodThrowing(JoinPoint joinPoint, Exception e) {String methodName = joinPoint.getSignature().getName();System.out.println("Method " + methodName + " threw exception: " + e.getMessage());}@After("execution(* com.example.MyService.*(..))")public void afterMethodExecution(JoinPoint joinPoint) {String methodName = joinPoint.getSignature().getName();System.out.println("After executing method: " + methodName);}
}

ps:以下是我整理的java面试资料,密码是obht,感兴趣的可以看看。最后,创作不易,觉得写得不错的可以点点关注!

链接:https://www.yuque.com/u39298356/uu4hxh?# 《Java面试宝典》 

http://www.shuangfujiaoyu.com/news/34212.html

相关文章:

  • 做关于车的网站好网络营销的四种模式
  • 岳阳公司网站开发seo优化推荐
  • 生物制药公司网站建设品牌网络推广外包
  • 本地电脑独立ip做网站什么平台推广效果最好
  • 百度验证网站操作百度浏览器网页版
  • 新闻网站开发实例百度开户联系方式
  • 网站建设项目报价淘宝的17种免费推广方法
  • 做淘宝需要的网站成都公司建站模板
  • 做电商的几个网站吗竞价推广哪里开户
  • 百度网盘做网站网站排名优化
  • 网页设计图片素材网seo网络营销推广公司深圳
  • 无锡网络公司无锡网站推广网络安全培训最强的机构
  • 手机网站哪家好东莞推广平台有哪些
  • 茂名网站制作计划典型的口碑营销案例
  • 北京网站建设 知乎网络营销的缺点及建议
  • 国外独立网站建设百度销售平台
  • 做网站卖什么发财百度指数分析工具
  • 酒店类网站开发的策略免费网站软件推荐
  • 网站域名密码快速seo优化
  • 软件开发文档编写规范廊坊百度关键词优化怎么做
  • 百度网站的网址网站推广的常用方法
  • 个人app开发平台免费上海专业的seo推广咨询电话
  • 钦州公司做网站软文发稿系统
  • 北京手机站建站广西网站seo
  • 浏览网站怎么用手机做营销渠道的概念
  • 做互联网网站的会抓百度公司招聘2022年最新招聘
  • 百度个人网站建设站长工具果冻传媒
  • 有人和兽做的网站百度一下免费下载
  • 网络营销是什么的组成部分兰州seo
  • 企业网站开发设计找个免费的网站