1. 需要使用的jar包
asm-3.3.jar
aspectjrt.jar
aspectjweaver.jar
cglib-nodep-2.1_3.jar
spring-aop.jar
2. XML配置文件
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<bean id="aopHandler2" class="com.spring.service.TestAop"></bean>
<aop:config>
<aop:aspect ref="aopHandler2">
<aop:pointcut id="poicut" expression="execution(* com.spring.dao.*.*(..))" /> <!-- 这里可以看spring aop expression简单说明 -->
<!-- method 指出before要调用的方法 -->
<aop:before method="testPrint" pointcut-ref="poicut"/>
</aop:aspect>
</aop:config>
</beans>