Spring——APO(待完)
导入依赖包
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.9.6</version>
</dependency>
方式一:使用Spring的API接口(接口实现:MethodBeforeAdvice、AfterReturningAdvice)
execution(修饰符 返回值 包名.类名/接口名.方法名(参数列表))上面忽略掉修饰符了 (..)可以代表所有参数,( * )代表一个参数,(*,String)代表第一个参数为任何值,第二个参数为String类型
方式二:自定义实现(切面定义)
<!--方式二:自定义类-->
<bean id="diy" class="com.yl.diy.DiyPointCut"/>
<aop:config>
<!--自定义切面,ref要引用的类-->
<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/>
浙公网安备 33010602011771号