简体   繁体   中英

Using @annotation in Spring AOP

I am using Spring AOP with aspectj-autoproxy. I use the @Around annotation to intercept certain classes and methods.

@Around(value = "@annotation(counter)")

This code should intercept methods annotated with @Counter annotation.

My question is, does this definition forces scan of all classes in the class path? I am asking because I have a huge project that can suffer several minutes of loading time if all the class path will be scanned.

And if the answer is yes, how can I disable he scanning?

它只会扫描定义的Spring bean,因此不会扫描完整的类路径。.此外,应将注释@Counter指定为完全合格的类名,我认为“ counter”不是正确的类名。

使用以下方式限制扫描:

execution(* com.my.package..*.*(..)) && @annotation(counter)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM