<!-- 配置 Service 层日志记录 -->
<bean id="serviceLogging" class="com.ken.wms.util.aop.ServiceLogging"/>
<!-- 配置用户操作日志记录 -->
<bean id="userOperationLogging" class="com.ken.wms.util.aop.UserOperationLogging"/>
<!-- AOP 配置 -->
<aop:config>
<aop:pointcut id="serviceMethodLoggingPointcut" expression="execution(* com.ken.wms.common.service.Impl.*.*(..)) ||
execution(* com.ken.wms.security.service.Impl.*.*(..))"/>
<aop:aspect id="serviceLoggingAspect" ref="serviceLogging" order="100">
<aop:before method="loggingMethodInvoked" pointcut-ref="serviceMethodLoggingPointcut"/>
<aop:after-throwing method="loggingServiceException" pointcut-ref="serviceMethodLoggingPointcut"
throwing="throwable"/>
</aop:aspect>
</aop:config>
<aop:config>
<aop:pointcut expression="execution(* com.ken.wms.common.service.Impl.*.*(..)) and @annotation(userOperation)"
id="userOperationLoggingPointcut"/>
<aop:aspect id="userOperationLoggingAspect" ref="userOperationLogging" order="20">
<aop:after-returning method="loggingUserOperation" pointcut-ref="userOperationLoggingPointcut"
returning="returnValue"/>
</aop:aspect>
</aop:config>
记录一个有意思的spring aop配置
最新推荐文章于 2024-09-30 10:36:33 发布