springAOP中Pointcut注解表达式@target、@annotation、@within、this、target、within等
发布日期:2021-06-20 07:26:21 浏览次数:26 分类:技术文章

本文共 1097 字,大约阅读时间需要 3 分钟。

至于最常见的 execution表达式;由于网上一搜基本都是用的这个,这里就不在赘述了;这里将我知道的分享给大家;

//@Around("@annotation(自定义注解)")//自定义注解标注在方法的方法执行aop方法

如:@Around("@annotation(org.springframework.transaction.annotation.Transactional)")

//@Around("@within(自定义注解)")//自定义注解标注在的;该类的所有方法(不包含子类方法)执行aop方法

如:@Around("@within(org.springframework.transaction.annotation.Transactional)")

//@Around("within(包名前缀.*)")//com.aop.within包下所有类的所有的方法都会执行(不包含子包) aop方法

如:@Around("within(com.aop.test.*)")

//@Around("within(包名前缀..*)")//com.aop.within包下所有的方法都会执行(包含子包)aop 方法

如:@Around("within(com.aop.test..*)")

//@Around("this(java类或接口)")//实现了该接口的类、继承该类、该类本身的类---的所有方法(包括不是接口定义的方法,但不包含父类的方法)都会执行aop方法

如:@Around("this(com.aop.service.TestService)")

//@Around("target(java类或接口)")//实现了该接口的类、继承该类、该类本身的类---的所有方法(包括不是接口定义的方法,包含父类的方法)

如:@Around("this(com.aop.service.TestService)")

//@Around("@target(自定义注解)")//springboot项目启动报如下错误,没有解决

// Caused by: java.lang.IllegalStateException:
// StandardEngine[Tomcat].StandardHost[localhost].TomcatEmbeddedContext[] failed to start
目前分享到这里了!

————————————————
原文链接:https://blog.csdn.net/scos_sxb/article/details/100945389

转载地址:https://blog.csdn.net/HD243608836/article/details/101301992 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:SpringAOP中Aspectj拦截所有方法含有某个注解,并且排除某些包下的某些类的方法上也含有这个注解的方法
下一篇:centos7安装MongoDB3.4

发表评论

最新留言

第一次来,支持一个
[***.219.124.196]2024年04月05日 08时17分44秒

关于作者

    喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!

推荐文章