LogAspect.java

865 단어 LogAspectLogAspect

java/com/example/aop/LogAspect.java
공통 작업을 구현하기 위한 용도

package com.example.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class LogAspect {

    // 패키지가 com.example.controller인 컴트롤러는 모두 수행
    @Around("execution(* com.example.controller.*Controller.*(..)) or execution(* com.example.mapper.*Mapper.*(..))")
    public Object printLog(ProceedingJoinPoint joinPoint) throws Throwable {
        String className = joinPoint.getSignature().getDeclaringTypeName();
        String methodName = joinPoint.getSignature().getName();
        System.out.println("클래스명: "+ className + "메소드명: " + methodName);
        return joinPoint.proceed();
    }
}

좋은 웹페이지 즐겨찾기