您的位置:首页 > 编程语言 > Java开发

记录一个有意思的spring aop配置

2020-03-08 12:38 162 查看
<!-- 配置 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>
  • 点赞
  • 收藏
  • 分享
  • 文章举报
南阳木子 发布了42 篇原创文章 · 获赞 4 · 访问量 9152 私信 关注
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: