配置文件两种:
1、
<aop:config>
<aop:pointcut id="ctrlOperation" expression="execution(* com.tuniu..*Controller.*(..))" />
<aop:pointcut id="ctrlAPI" expression="execution(* com.tuniu..*API.*(..))" />
<aop:advisor advice-ref="loginInfoAdvice" pointcut-ref="ctrlOperation" />
<aop:advisor advice-ref="loginInfoAdvice" pointcut-ref="ctrlAPI" />
<aop:advisor advice-ref="dataSourceAdvice" pointcut-ref="ctrlOperation" />
</aop:config>
<bean id="dataSourceAdvice" class="com.tuniu.scc.stock.manage.common.db.DataSourceAdvice" />
<bean id="loginInfoAdvice" class="com.tuniu.scc.stock.manage.common.login.CookieAdvice" />
2、
<aop:config>
<aop:aspect id="TestAspect" ref="aspectBean">
<!--配置com.spring.service包下所有类或接口的所有方法-->
<aop:pointcut id="businessService"
expression="execution(* com.spring.service.*.*(..))" />
<aop:before pointcut-ref="businessService" method="doBefore"/>
<aop:after pointcut-ref="businessService" method="doAfter"/>
<aop:around pointcut-ref="businessService" method="doAround"/>
<aop:after-throwing pointcut-ref="businessService" method="doThrowing" throwing="ex"/>
</aop:aspect>
</aop:config>
<bean id="aspectBean" class="com.spring.aop.TestAspect" />