使用SpringAOP实现自定义注解之切入点表达式

匿名 (未验证) 提交于 2019-12-02 23:34:01
版权声明:本文为博主原创文章。 https://blog.csdn.net/qq_36691683/article/details/90311847

使用Spring AOP实现自定义注解时,关键在于切入点PointCut表达式的书写,即通过表达式扫描指定的注解。

以下给出两种写法,这两种写法都可以扫描指定包下的注解。

1、

@Around("execution(@com.fish.annotation.LogRunTime * com.fish.handler.*.*(..))") public void authority(ProceedingJoinPoint proceedingJoinPoint) throws Throwable 

2、

@Around("within(com.fish..*) && @annotation(lrt)") public void authority(ProceedingJoinPoint proceedingJoinPoint, LogRunTime lrt) throws Throwable 

Spring.xml配置:

    <aop:aspectj-autoproxy/>     <context:component-scan base-package="com.fish"/> 

参考资料:

https://blog.csdn.net/qq_36951116/article/details/79172485

文章来源: https://blog.csdn.net/qq_36691683/article/details/90311847
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!