AOP 설정방법 - @annotation

AOP 설정방법 - @annotation

1. Controller에서 @anntation 붙이기

Controller

2. @annotation interface 만들기

public @interface ParameterCheck { }

3. @annotation 구현체 만들기

@Aspect @Component public class ParameterCheckAspect { @Pointcut("@annotation(com.test.test1.api.aop.aspect.ParameterCheck)") public void parameterCheck() { } @Before("parameterCheck()") public void checkParameter() throws Throwable { HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()) .getRequest(); HttpServletResponse response = ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()) .getResponse(); System.out.println("=== AOP TEST ==="); } }

4. aop xml에 설정 붙이기

5. pom.xml 추가

org.springframework spring-aspects ${org.springframework-version}

spring AOP설정은 여러가지 방법이 있는데 @annocation을 이용하여 설정하는게 직관적이라 보기 좋은거 같다...

from http://rlawls1991.tistory.com/54 by ccl(A) rewrite - 2020-03-25 10:20:24

댓글

이 블로그의 인기 게시물

[Linux] 파일 로그 보기(tail)

[샤니마스 SPRING PARTY2020] THE IDOLM @ STER SHINY COLORS SPRING...

2020 LCK 롤챔스 Spring 경기 재개 및 일정