<bean id="fooService" class="spring.aop.DefaultFooService" />
<bean id="aopInject" class="spring.aop.AopInject"></bean>
<aop:config>
<aop:aspect ref="aopInject">
<aop:pointcut expression="execution(* spring.aop.FooService.getFoo(String,int))" id="allExecution"/>
<aop:before method="injectMethod" pointcut-ref="allExecution"/>
</aop:aspect>
</aop:config>
AopInject类, 代理类:
public class AopInject {
public void injectMethod() throws Throwable {
System.out.println("AopInject类注入");
}
}
[color=red]注意事项PS:
用before和after, 代理类不支持方法参数ProceedingJoinPoint,所以必须去掉该参数
[/color]