You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
예제 만들기
@Trace애노테이션으로 로그 출력하기@Retry애노테이션으로 예외 발생시 재시도 하기ExamRepository
ExamService
ExamTest
로그 출력 AOP
@trace
TraceAspect
ExamService -
@Trace추가@Trace를 붙였다. 이제 메서드 호출 정보를 AOP를 사용해서 로그로 남길 수 있다.ExamRepository -
@Trace추가@Trace를 붙였다.ExamTest - 추가
@Import(TraceAspect.class)를 사용해서TraceAspect를 스프링 빈으로 추가하자. 이제 애스펙트가 적용된다.실행 결과

@Trace가 붙은 request() , save() 호출시 로그가 잘 남는 것을 확인할 수 있다.재시도 AOP
@Retry애노테이션이 있으면 예외가 발생했을 때 다시 시도해서 문제를 복구한다.@RetryRetryAspect
@annotation(retry), Retry retry 를 사용해서 어드바이스에 애노테이션을 파라미터로 전달한다.ExamRepository - @Retry 추가
시도 한다.
ExamTest - 추가
실행 결과

참고
@Transactional은 가장 대표적인 AOP이다.Beta Was this translation helpful? Give feedback.
All reactions