1.配置spring容器

导入jar包  

    com.springsource.net.sf.cglib-2.2.0.jar
    com.springsource.org.aopalliance-1.0.0.jar
    com.springsource.org.aspectj.weaver-1.6.8.RELEASE.jar
    commons-logging-1.1.3.jar
    spring-aop-4.2.2.RELEASE.jar
    spring-beans-4.2.2.RELEASE.jar
    spring-context-4.2.2.RELEASE.jar
    spring-core-4.2.2.RELEASE.jar
    spring-expression-4.2.2.RELEASE.jar

配置xml文件

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <beans xmlns="http://www.springframework.org/schema/beans"
 3     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 4     xmlns:p="http://www.springframework.org/schema/p"
 5     xmlns:aop="http://www.springframework.org/schema/aop"
 6     xmlns:context="http://www.springframework.org/schema/context"
 7     xsi:schemaLocation="http://www.springframework.org/schema/beans
 8         http://www.springframework.org/schema/beans/spring-beans.xsd
 9         http://www.springframework.org/schema/context
10         http://www.springframework.org/schema/context/spring-context.xsd
11         http://www.springframework.org/schema/aop
12         http://www.springframework.org/schema/aop/spring-aop.xsd">
13     
14     <!-- 包扫描 -->
15     <context:component-scan base-package="com.eduask.liusheng.aop.after"/>
16     
17     <!-- 开启切面 -->
18     <aop:aspectj-autoproxy></aop:aspectj-autoproxy>
19 </beans>
applicationContext-aop-annotation.xml

相关文章: