본문 바로가기

Spring64

Spring Framework annotation 정리 참고 글 : https://sddev.tistory.com/225 [Spring Boot] 어노테이션 정리 SpringBoot란? Spring에서는 이러한 설정들을 자동화해주는 SpringBoot라는 프로젝트를 만들었다. Spring에서 SpringBoot라는 프레임워크를 내놓기 시작하면서 SpringBoot의 AutoConfigure(자동 구성) 기능을 통해 sddev.tistory.com SpringBoot란? Spring에서는 이러한 설정들을 자동화해주는 SpringBoot라는 프로젝트를 만들었다. Spring에서 SpringBoot라는 프레임워크를 내놓기 시작하면서 SpringBoot의 AutoConfigure(자동 구성) 기능을 통해 많은 설정들이 자동화되기 시작하였다. Quick하게 정리하는.. 2023. 8. 23.
스프링 AOP - 실무 주의사항 프록시와 내부 호출 - 문제 대상 객체의 내부에서 메서드 호출이 발생하면 프록시를 거치지 않고 대상 객체를 직접 호출하는 문제가 발생한다. CallServiceV0 @Slf4j @Component public class CallServiceV0 { public void external() { log.info("call external"); internal(); //내부 메서드 호출(this.internal()) } public void internal() { log.info("call internal"); } } CallServiceV0Test @Test void external() { callServiceV0.external(); } @Test void internal() { callServiceV0... 2023. 8. 22.
스프링 AOP - 예제 로그 출력 AOP @Trace @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) public @interface Trace { } TraceAspect @Slf4j @Aspect public class TraceAspect { @Before("@annotation(hello.aop.exam.annotation.Trace)") public void doTrace(JoinPoint joinPoint) { Object[] args = joinPoint.getArgs(); log.info("[trace] {} args={}", joinPoint.getSignature(), args); } } → @Trace가 붙은 메서드에 어드바이스 적용 재시도 .. 2023. 8. 22.
스프링 AOP - 포인트컷 포인트컷 지시자(Pointcut Designator) 포인트컷 지시자의 종류 execution : 메소드 실행 조인 포인트를 매칭. within : 특정 타입 내의 조인 포인트를 매칭. args : 인자가 주어진 타입의 인스턴스인 조인 포인트 this : 스프링 빈 객체(스프링 AOP 프록시)를 대상으로 하는 조인 포인트 target : Target 객체(스프링 AOP 프록시가 가르키는 실제 대상)를 대상으로 하는 조인 포인트 @target : 실행 객체의 클래스에 주어진 타입의 애노테이션이 있는 조인 포인트 @within : 주어진 애노테이션이 있는 타입 내 조인 포인트 @annotation : 메서드가 주어진 애노테이션을 가지고 있는 조인 포인트를 매칭 @args : 전달된 실제 인수의 런타임 타입이.. 2023. 8. 21.