spring-boot-starter-aop-2.6.6.jar下载(download)

摘要

Spring Boot使用AOP需要添加spring-boot-starter-aop依赖,如下:<dependency><groupId>org springframework boot< groupId><artifactId>s

书单推荐:成为Java顶级程序员架构师 ,这20来本(高薪)必看点击获取

书单推荐:成为Java顶级程序员架构师 ,这20来本(高薪)必看点击获取

Spring Boot使用AOP需要添加spring-boot-starter-aop依赖,如下:

<dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-aop</artifactId>

</dependency>

不需要再添加aspectjweaver的依赖了,因为spring-boot-starter-aop包含了aspectjweaver,并且版本是较新的版本,如果在添加老版本(如1.5.4)启动会报错。


原则上来说,我们只要引入 Spring 框架中 AOP 的相应依赖就可以直接使用 Spring 的 AOP 支持了,不过,为了进一步为大家使用 SpringAOP 提供便利,SpringBoot 还是“不厌其烦”地为我们提供了一个 spring-boot-starter-aop 自动配置模块。


spring-boot-starter-aop 自动配置行为由两部分内容组成:

位于 spring-boot-autoconfigure的org.springframework.boot.autoconfigure.aop.AopAutoConfiguration 提供 @Configuration 配置类和相应的配置项。

spring-boot-starter-aop 模块自身提供了针对 spring-aop、aspectjrt 和 aspectjweaver 的依赖。


一般情况下,只要项目依赖中加入了 spring-boot-starter-aop,其实就会自动触发 AOP 的关联行为,包括构建相应的 AutoProxyCreator,将横切关注点织入(Weave)相应的目标对象等,不过 AopAutoConfiguration 依然为我们提供了可怜的两个配置项,用来有限地干预 AOP 相关配置:

spring.aop.auto=true

spring.aop.proxy-target-class=false