Spring——APO(待完)
导入依赖包
<dependency>
<groupId>org.aspectjgroupId>
<artifactId>aspectjweaverartifactId>
<version>1.9.6version>
dependency>
方式一:使用Spring的API接口(接口实现:MethodBeforeAdvice、AfterReturningAdvice)
execution(修饰符 返回值 包名.类名/接口名.方法名(参数列表))上面忽略掉修饰符了 (..)可以代表所有参数,( * )代表一个参数,(*,String)代表第一个参数为任何值,第二个参数为String类型
方式二:自定义实现(切面定义)
<bean id="diy" class="com.yl.diy.DiyPointCut"/>
<aop:config>
<aop:aspect ref="diy">
<aop:pointcut id="point" expression="execution(* com.yl.service.UserServiceImpl.*(..))"/>
<aop:before method="before" pointcut-ref="point"/>
<aop:after method="after" pointcut-ref="point"/>
aop:aspect>
aop:config>
方式三:注解实现
//使用注解实现AOP
顺序:around-before-after-around
xml配置
<bean id="annotationPointCut" class="com.yl.diy.AnnotationPointCut"/>
<aop:aspectj-autoproxy/>