博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
spring AOP打印方法名字
阅读量:3951 次
发布时间:2019-05-24

本文共 1462 字,大约阅读时间需要 4 分钟。

package com.example.mongodemo.config;import lombok.extern.slf4j.Slf4j;import org.aspectj.lang.JoinPoint;import org.aspectj.lang.annotation.Aspect;import org.aspectj.lang.annotation.Before;import org.aspectj.lang.annotation.Pointcut;import org.springframework.stereotype.Component;/** * @Author lyr * @create 2020/3/31 15:25 */@Aspect@Component@Slf4jpublic class AopLogger {
@Pointcut(value = "execution(* com.example.mongodemo.mapper..*.*(..))") public void beforeCut(){
} @Before(value = "beforeCut()") public void before(JoinPoint joinPoint) {
if (joinPoint==null) {
return; } String className = joinPoint.getTarget().getClass().getName(); String methodName = joinPoint.getSignature().getName(); log.info("\r\n\r\nDAO层 运行信息:{} -> {}\r\n\r\n",className,methodName); } @Pointcut(value = "execution(* com.example.mongodemo.service.impl..*.*(..))") public void beforeCut2(){
} @Before(value = "beforeCut2()") public void before2(JoinPoint joinPoint) {
if (joinPoint==null) {
return; } log.info("-------------------------------------\r\n\r\n"); String className = joinPoint.getTarget().getClass().getName(); String methodName = joinPoint.getSignature().getName(); log.info("\r\nService 层 运行信息:{} -> {}\r\n",className,methodName); log.info("\r\n-------------------------------------------------\r\n"); }}

转载地址:http://xauzi.baihongyu.com/

你可能感兴趣的文章
Reward HDU - 2647 (拓扑排序)
查看>>
最长子序列长度 (动态规划 O(N^2))
查看>>
最长子序列长度 (贪心+二分 O( Nlog(N) ))
查看>>
数塔 HDU - 2084 (简单的dp)
查看>>
超级楼梯 HDU - 2041 ( 简单的dp )
查看>>
Piggy-Bank HDU - 1114 ( 完全背包 )
查看>>
Knapsack problem FZU - 2214 ( 01背包 )
查看>>
瞌睡 (网易笔试题)
查看>>
1009 说反话 (20 分)
查看>>
1010 一元多项式求导 (25 分)
查看>>
1011 A+B 和 C (15 分)
查看>>
1012 数字分类 (20 分)
查看>>
1013 数素数 (20 分)
查看>>
1014 福尔摩斯的约会 (20 分)
查看>>
1015 德才论 (25 分)
查看>>
1016 部分A+B (15 分)
查看>>
1017 A除以B (20 分)
查看>>
1019 数字黑洞 (20 分)
查看>>
1032 挖掘机技术哪家强 (20 分)
查看>>
今夕何夕 HDU - 6112 ( 模拟 )
查看>>