Skip to content

Files

Latest commit

a0c9a45 · Jan 19, 2024

History

History
This branch is 33 commits ahead of, 25 commits behind 3.3.x.

demo-spring-boot-aop

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Jan 19, 2024
Jan 11, 2024
Aug 27, 2021
Method method = ((MethodSignature) joinPoint.getSignature()).getMethod();
LogExecutionTime annotation = method.getAnnotation(LogExecutionTime.class);
String key = annotation.key();
String cacheName = annotation.cacheName();
boolean needLog = annotation.needLog();
@Around("@annotation(com.fengwenyi.springbootaopdemo.annotation.LogExecutionTime)")
    public Object logExecutionTime1(ProceedingJoinPoint joinPoint) throws Throwable {

execution(* com.sample.service.impl...(..))

解释如下:

符号 含义 execution() 表达式的主体; 第一个”“符号 表示返回值的类型任意; com.sample.service.impl AOP所切的服务的包名,即,我们的业务部分 包名后面的”..“ 表示当前包及子包 第二个”“ 表示类名,即所有类。此处可以自定义,下文有举例 .(..) 表示任何方法名,括号表示参数,两个点表示任何参数类型

MyFirstAspect#around execute start MySecondAspect#around execute start ExampleAspect#around execute start ExampleAspect#around execute end url:, 耗时:0.7597495250474953毫秒 MySecondAspect#around execute end MyFirstAspect#around execute end

使用注解的优先级高于包扫描