xml文件中 aop的配置

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.2.xsd"
xmlns:aop="http://www.springframework.org/schema/aop">



<bean id="timeHandler" class="切入类路径"/>
<bean id="videoService" class="具体实现类路径"/>
<!--aop配置-->
<aop:config >

<!-- 横切关注点-->
<aop:aspect id="timeAspect" ref="timeHandler">
<!-- 定义切面表达式-->
<aop:pointcut id="allMethodLogPointCut" expression="execution(* 具体实现类接口.*(..))"/>
<!-- 配置前置通知和后置通知-->
<aop:before method="前置通知" pointcut-ref="allMethodLogPointCut"/>
<aop:after method="后置通知" pointcut-ref="allMethodLogPointCut"/>
</aop:aspect>

</aop:config>
</beans>


pom文件中需要的依赖

<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.9.5</version>
</dependency>
posted @ 2021-11-27 14:49  智慧搬运工  阅读(121)  评论(0)    收藏  举报