导入Spring Aop的包
配置文件实现Aop只需在配置文件中加入本段代码
<!-- 使用配置文件实现AOP -->
<aop:config>
<aop:aspect ref="logInterceptor" >
<aop:pointcut expression="execution(public * com.web.service.impl.*.*(..))" id="myMethod"/>
<aop:before method="before" pointcut-ref="myMethod"/>
<aop:after method="after" pointcut-ref="myMethod"/>
<aop:after-returning method="afterReturning" pointcut-ref="myMethod"/>
<aop:after-throwing method="afterThrowing" pointcut-ref="myMethod"/>
<aop:around method="around" pointcut-ref="myMethod"/>
</aop:aspect>
</aop:config>
其中ref表示切面, <aop:pointcut expression=“execution(public * com.web.service.impl..(…))” id=“myMethod”/>表示要切入的位置,
<aop:before method=“before” pointcut-ref=“myMethod”/>
<aop:after method=“after” pointcut-ref=“myMethod”/>
表示切入的时机。