版权声明:本文为博主原创文章。 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