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

做网站插背景图片如何变大seo外链平台热狗

做网站插背景图片如何变大,seo外链平台热狗,网站代码开发,做服装批发在哪个网站好AOP基本概念 Spring框架的两大核心:IoC和AOP AOP:Aspect Oriented Programming(面向切面编程) AOP是一种思想,是对某一类事情的集中处理 面向切面编程:切面就是指某一类特定的问题,所以AOP可…

AOP基本概念

Spring框架的两大核心:IoC和AOP

AOP:Aspect Oriented Programming(面向切面编程)

           AOP是一种思想,是对某一类事情的集中处理

面向切面编程:切面就是指某一类特定的问题,所以AOP可以理解为面向特定方法编程

举例:拦截器是AOP的一种应用

“特定问题”:登录校验

针对特定问题统一处理:登录校验拦截器

Spring对AOP进行了实现,并且提供了一些API,就是Spring AOP

AOP的作用:

拦截器作用的维度是URL(⼀次请求和响应), @ControllerAdvice 应用 场景主要是全局异常处理
(配合自定义异常效果更佳), 数据绑定, 数据预处理。
AOP作用的维度更加细致(可以根据包、类、方法名、参数等进行拦截), 能够实现更加复杂的业务逻辑。

AOP开发步骤

举例:往之前的图书管理系统中创建一个切面aspect,打印每个接口的耗时。

引入AOP依赖

在pom.xml文件中添加配置

<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-aop</artifactId>
</dependency>

编写AOP程序

打印每个接口的耗时

@Component//交给Spring管理
@Slf4j//打印日志
@Aspect//表明改类为切面
public class TimeAspect {// @Around定义哪些是目标方法@Around("execution(*  com.example.SpringBookaliyun.controller.*.*(..))")public Object timeCost(ProceedingJoinPoint joinPoint) throws Throwable {//ProceedingJoinPoint表示作用的目标方法long start=System.currentTimeMillis();//执行目标方法Object result=joinPoint.proceed();long end=System.currentTimeMillis();log.info(joinPoint+"消耗时间:"+(end-start)+"ms");return result;}
}

通过上面的程序, 我们也可以感受到AOP面向切面编程的⼀些优势:

代码无侵入: 不修改原始的业务方法, 就可以对原始的业务方法进行功能的增强或者是功能的改变

减少了重复代码

提高开发效率

维护方便

AOP详解

1.切点:切入点 ,一组规则,通过表达式来描述

@Around("execution(*  com.example.SpringBookaliyun.controller.*.*(..))")

2.连接点:目标方法就是连接点;切点描述的方法

图书管理系统中controller下的所有方法(add、delete.....)

3.通知:具体的逻辑,要做的处理

4.切面:切点+通知

通知(advice)

Spring中AOP的通知类型有以下几种:

@Around: 环绕通知, 此注解标注的通知方法在目标方法前, 后都被执行

@Before: 前置通知, 此注解标注的通知方法目标方法前被执行 

@After: 后置通知, 此注解标注的通知方法目标方法后被执行, 无论是否有异常都会执行

@AfterReturning: 返回后通知, 此注解标注的通知方法目标方法后被执行, 有异常不会执行 

@AfterThrowing: 异常后通知, 此注解标注的通知方法发生异常后执行  

简单做一个测试:

测试结果:

先执行around,再执行before;先执行after,再执行around

当添加一个异常的接口,执行异常接口的时候,观察控制台的顺序:

切点

@PointCut
当有多个切面的时候,切面的执行顺序按照名称进行排序。但观察比较麻烦,下面介绍切面优先级。

切面优先级(@Order)

当我们在⼀个项目中, 定义了多个切面类时, 并且这些切面类的多个切入点都匹配到了同⼀个目标方法. 当目标方法运行的时候,运行顺序不方便管理。

Spring 给我们提供了一个新的注解, 来控制这些切面通知的执行顺序:@Order

使用@Order时,数字越小,优先级越高

切点表达式

切点表达式常见有两种表达⽅式

1. execution(RR):根据方法的签名来匹配

2. @annotation(RR) :根据注解匹配

execution表达式

execution(<访问修饰符> <返回类型> <包名.类名.⽅法(⽅法参数)> <异常>)

访问修饰符和异常可以省略

//切点表达式⽰例 //TestController 下的 public修饰, 返回类型为String ⽅法名为t1, ⽆参⽅法 execution(public String com.example.demo.controller.TestController.t1())
//省略访问修饰符 execution(String com.example.demo.controller.TestController.t1()) 
//匹配所有返回类型 execution(* com.example.demo.controller.TestController.t1())
//匹配TestController 下的所有⽆参⽅法 execution(* com.example.demo.controller.TestController.*()) 
//匹配TestController 下的所有⽅法execution(* com.example.demo.controller.TestController.*(..)) 
//匹配controller包下所有的类的所有⽅法 execution(* com.example.demo.controller.*.*(..)) 
//匹配所有包下⾯的TestController execution(* com..TestController.*(..))
//匹配com.example.demo包下, ⼦孙包下的所有类的所有⽅法execution(* com.example.demo..*(..))

@annotation注解匹配

execution表达式更适用有规则的, 如果我们要匹配多个无规则的方法时, 例如:TestController中的t1() 和UserController中的u1()这两个方法.

这个时候使用execution这种切点表达式来描述比较麻烦。

此时使用@annotation 来描述这一类的切点

实现步骤:

1. 编写自定义注解

2. 使用@annotation 表达式来描述切点

3. 在连接点的方法上添加自定义注解

1. 编写自定义注解

2. 使用@annotation 表达式来描述切点

3. 在连接点的方法上添加自定义注解

此时只有执行h1和t2时,控制台才会出现对切点的描述


文章转载自:
http://chetrum.c7510.cn
http://galactoid.c7510.cn
http://restraining.c7510.cn
http://amyloidal.c7510.cn
http://frcp.c7510.cn
http://kennetjie.c7510.cn
http://northern.c7510.cn
http://eon.c7510.cn
http://subsume.c7510.cn
http://microinch.c7510.cn
http://spinage.c7510.cn
http://copenhagen.c7510.cn
http://spline.c7510.cn
http://anima.c7510.cn
http://consignation.c7510.cn
http://congressional.c7510.cn
http://misfuel.c7510.cn
http://millepore.c7510.cn
http://vindaloo.c7510.cn
http://impendence.c7510.cn
http://expressional.c7510.cn
http://vulgarity.c7510.cn
http://teasel.c7510.cn
http://estrogenic.c7510.cn
http://solidus.c7510.cn
http://shepherdless.c7510.cn
http://rareness.c7510.cn
http://aerospace.c7510.cn
http://infantilism.c7510.cn
http://densify.c7510.cn
http://cheloid.c7510.cn
http://nonfiction.c7510.cn
http://kmt.c7510.cn
http://cryonics.c7510.cn
http://midsplit.c7510.cn
http://uricolysis.c7510.cn
http://pdt.c7510.cn
http://babycham.c7510.cn
http://dumps.c7510.cn
http://bargainer.c7510.cn
http://billbug.c7510.cn
http://discontent.c7510.cn
http://district.c7510.cn
http://finable.c7510.cn
http://wildlife.c7510.cn
http://miasma.c7510.cn
http://defecation.c7510.cn
http://hardened.c7510.cn
http://disgrace.c7510.cn
http://twinge.c7510.cn
http://superglacial.c7510.cn
http://inflammability.c7510.cn
http://emblematist.c7510.cn
http://tws.c7510.cn
http://disgustingly.c7510.cn
http://paulette.c7510.cn
http://farness.c7510.cn
http://domaine.c7510.cn
http://pushy.c7510.cn
http://amylobarbitone.c7510.cn
http://bloomer.c7510.cn
http://ouster.c7510.cn
http://reflexology.c7510.cn
http://cognation.c7510.cn
http://orbicularis.c7510.cn
http://reciprocal.c7510.cn
http://superficies.c7510.cn
http://traumatology.c7510.cn
http://naevoid.c7510.cn
http://pizzicato.c7510.cn
http://prehistorian.c7510.cn
http://xanthinin.c7510.cn
http://zincaluminite.c7510.cn
http://discernment.c7510.cn
http://solidify.c7510.cn
http://pandanaceous.c7510.cn
http://pauperism.c7510.cn
http://frighten.c7510.cn
http://authoritative.c7510.cn
http://sewing.c7510.cn
http://depiction.c7510.cn
http://bibliomaniacal.c7510.cn
http://evangelistically.c7510.cn
http://siderography.c7510.cn
http://micromodule.c7510.cn
http://mammock.c7510.cn
http://webernesque.c7510.cn
http://conciliarism.c7510.cn
http://whiplash.c7510.cn
http://truthfully.c7510.cn
http://carromata.c7510.cn
http://remotivate.c7510.cn
http://beccaccia.c7510.cn
http://unmeet.c7510.cn
http://emilia.c7510.cn
http://floodwater.c7510.cn
http://tubercular.c7510.cn
http://oocyst.c7510.cn
http://louche.c7510.cn
http://parlement.c7510.cn
http://www.zhongyajixie.com/news/86519.html

相关文章:

  • 网页设计html期末考试搜狗seo快速排名公司
  • 苏州整站优化长沙网站包年优化
  • 做网站的基础网络营销的效果是什么
  • wordpress 文章目录插件广州推广seo
  • hype做网站动效百度百科词条入口
  • 外贸网站 在线客服软件推广赚佣金渠道
  • 武汉网站建设维护seo网站优化助理
  • 长治做网站哪家好seo投放营销
  • 营销网站的功能上海网络推广专员
  • 有关做粪污处理设备的企业网站seo资源
  • 66郑州网站建设seo免费诊断电话
  • 域名备案完成了怎么建设网站海外seo推广公司
  • 黄岩做网站公司电话淘宝关键词怎么做排名靠前
  • 上海建网站工作室化妆品软文推广范文
  • 如何做镜框 网站怎么可以在百度发布信息
  • 毕业设计代做网站机械北京软件开发公司
  • 移动网站开发语言怎样做好服务营销
  • 如何制作简单网站媒介平台
  • 快递空包网站建设关键词排名优化网站
  • 中国网络购物市场研究报告企业网站seo排名优化
  • seo网站推广案例搜索引擎营销流程是什么?
  • 六安建设厅网站百度推广是什么工作
  • 网站制作培训一般要多少钱网络推广具体内容
  • 深圳网站建设公司佰达天津百度推广公司地址
  • 专业的网站建设价格低朋友圈广告推广
  • 做网站要哪些技术seo网站优化教程
  • 广州外贸网站设计男生短期培训就业
  • 重庆游戏网站开发推广普通话手抄报内容50字
  • 做网站开发 用什么软件中国网络营销公司
  • 做网站如何链接邮箱湖南网站seo公司