SpringBoot AOP切入点表达式

介绍

在AOP中可以通过注解来定义 切入点表达式来控制被监控的方法。

匹配所有 com.example.service 包下以 Service 结尾的方法:

java 复制代码
"execution(* com.example.service.*Service.*(..))"

匹配任意类的 public 方法:

java 复制代码
"execution(public * *(..))"

匹配 com.example.service 包及其子包下的任意方法:

java 复制代码
"execution(* com.example.service..*.*(..))"

匹配 MyService 类中的 doSomething 方法:

java 复制代码
"execution(* com.example.service.MyService.doSomething(..))"

匹配 com.example.service 包中的任何类的 save 方法,且方法参数为 java.lang.String 类型

yaml 复制代码
"execution(* com.example.service.*.save(java.lang.String))"
相关推荐
掘金者阿豪2 小时前
高可用读写分离实战(二):我把数据库主库停了,结果整个集群的反应和我想象的不一样
后端
掘金者阿豪2 小时前
《高可用读写分离集群实战》系列(一)
后端
Dilee2 小时前
Spring AI 2.0.0 Prompt 最小 Demo:system、user、template 到底怎么分工
后端
未秃头的程序猿2 小时前
Java 26正式发布!这3个新特性,让代码量直接减半
java·后端·面试
小旭Coding2 小时前
卧靠!Go 传给前端的 int64 竟然变成了这个?
后端
用户298698530142 小时前
Word 文档文本查找与替换的 Java 实现方案
java·后端
kunge20132 小时前
深度剖析Claude Code 的CLAUDE.md加载逻辑
后端·vibecoding