在Spring AOP中使用@annotation

时间:2013-04-23 09:12:37

标签: java spring aop spring-aop

我正在使用带有aspectj-autoproxy的Spring AOP。 我使用@Around注释来拦截某些类和方法。

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

此代码应拦截使用@Counter注释注释的方法。

我的问题是,这个定义是否强制扫描类路径中的所有类? 我问,因为我有一个巨大的项目,如果将扫描所有类路径,可能会花费几分钟的加载时间。

如果答案是肯定的,我如何禁用他的扫描?

2 个答案:

答案 0 :(得分:0)

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

答案 1 :(得分:0)

使用以下方法限制扫描:

execution(* com.my.package..*.*(..)) && @annotation(counter)
相关问题