官方文檔中有寫:
You may register aspect classes as regular beans in your Spring XML configuration, or autodetect them through classpath scanning - just like any other Spring-managed bean. However, note that the @Aspect annotation is not sufficient for autodetection in the classpath: For that purpose, you need to add a separate @Component annotation (or alternatively a custom stereotype annotation that qualifies, as per the rules of Spring’s component scanner).
翻譯:
您可以在Spring XML配置中注冊aspect類,或者通過類路徑掃描自動檢測它們,就像任何其他Spring管理bean一樣。但是,請注意,@aspect注釋對於在類路徑中自動檢測是不夠的:為了達到這個目的,您需要添加一個單獨的@component注解(或者根據Spring的組件掃描器的規則來定義一個定制的原型注解)。
————————————————
版權聲明:本文為CSDN博主「todoliang」的原創文章,遵循 CC 4.0 BY-SA 版權協議,轉載請附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/woshiyigeliangliang/article/details/81450443
