Back-End/Spring8 Spring AOP : @Before와 Request로 ServletPath Logging 어제 수많은 구글링과 시도 끝에 @Before로 ServletPath를 Logging 하는 데 성공했다. AOP를 위해 작성한 Class LogAdvice의 코드는 다음과 같다 @Aspect @Component @Slf4j public class LogAdvice { @Autowired UserService service; @Before("execution (* com.cafe24.healthshare.controller.*Controller.*(..))") public void doLogging() throws Throwable{ HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.currentRequestAttri.. 2021. 3. 21. Spring AOP : pointcut is malformed 지금까지는 @Controller에서 각 메서드에 log를 남겼었다. 어느 순간 살펴보니 @Controller의 코드가 너무 지저분해서 AOP를 사용해서 Log를 남겨주려고 한다. AOP가 사실 어려운 건 아닌 것 같은데 잘 배우지 못해서 설정에 어려움이 있는 것 같다. 가장 먼저 마주친 문제는 Pointcut is malformed Error. malformed라는 단어도 고등학교 이후로 처음 본 것 같다. @Aspect @Component @Slf4j public class LogAdvice { @Before("execution(* com.cafe24.healthshare.service.UserService*.*(..))") public void test1(HttpRequest request) { lo.. 2021. 3. 20. 이전 1 2 다음