origoni's Blog from Millky

origoni의 스프링 블로그 입니다.

Spring에서 @Aspect @Pointcut 설정하기

포인트 컷으로 설정을 해두고 사용하는 방법도 있고.

@Pointcut("@annotation(org.springframework.web.bind.annotation.RequestMapping)")

public void joinPoint() {}
@Around("joinPoint()")

  

그냥 바로 적용하는 방식으로 할 수도 있다.

@Around("@annotation(org.springframework.web.bind.annotation.RequestMapping)")

 

--------------------------------------------------------------------------------

1. 컨트롤러 실행시

@Around("@annotation(org.springframework.web.bind.annotation.RequestMapping)")

 

2. Component 수행시(Repository, Controller, Service등을 포함한다.)

@Around("within(@(@org.springframework.stereotype.Component *) *)")

 

3. Repository 수행시
@Around("execution(public * net.byuri.model.repository..dao.*.*(..))")
@Around("within(@org.springframework.stereotype.Repository *) ")

 

위와 같은 방식을 사용할 수 있다.

 
back to top