본문 바로가기

Spring25

Spring AOP AOP (Aspect Oriented Programming) Aspect : 여러 클래스에 걸쳐 있는 관심사의 모듈화. - Java @AspectJ 선언 클래스 - XML ... Join point : 메소드 실행 또는 예외 처리와 같은 프로그램 실행 중인 지점. Spring AOP에서 조인점은 항상 메서드 실행을 나타냄. Advice : 특정 조인 포인트에서 애스펙트가 취하는 조치. 다른 타입의 "around", "before", "after" advice 포함. Pointcut : 조인 포인트와 일치하는 조건자. Advice는 포인트컷 표현식과 연관되며 포인트컷과 일치하는 모든 조인포인트에서 실행. - Java @Pointcut("execution(* run(..))") private void poi.. 2023. 3. 11.
Spring 빈이 아닌 클래스에서 빈 얻기 Spring 에서 간혹 @Component, @Controller, @Service, @Repository, @Bean 선언이 안된 일반클래스에서 스프링 빈을 가져와야 할 때가 있다. 여러가지 방식이 있겠으나 여기서는 그 중 하나의 방법으로 처리함. 1. 빈을 얻을 수 있는 클래스 선언 import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.stereotype.Component; @Component public class .. 2022. 8. 3.
Spring boot p6spy 적용 Spring boot 2.3.7 기준으로 쿼리 로깅하기 위한 p6spy 라이브러리를 적용해보자. 글 쓰는 시점 기준으로 쿼리 로깅하면 log4jdbc-log4j2 라이브러리를 적용했는데 이 라이브러리가 2013년 12월까지만 업데이트가 되어있어 p6spy 라이브러리를 쿼리 로깅으로 적용해보았다. 문제점은 로깅처리에 대한 이해가 더 필요할 것 같다. resultset, batch, 로깅 커스터마이징 처리 등... p6spy는 2020년 7월까지 릴리즈가 되어있다. 아래는 p6spy와 p6spy 적용한 spring boot URL이다. p6spy url : github.com/p6spy/p6spy p6spy/p6spy P6Spy is a framework that enables database data to.. 2021. 1. 7.
Spring batch chunk 동작 방식 Spring batch는 job을 기준으로 여러 step으로 수행이 이뤄지는데 step은 tasklet과 chunk로 나뉜다. 이 중 chunk 방식은 reader, processor, writer를 chunk size 기준으로 묶음단위로 동작하는 방식을 말한다. docs.spring.io/spring-batch/docs/4.3.x/reference/html/step.html#configureStep 위 그림처럼 chunk size 기준으로 (read -> processor) -> writer 단위로 수행되는데 그냥 보기에는 chunk size가 5라하면 (read -> processor) x 5 -> writer 이렇게 동작할거라 예상되지만 실제로는 (read x 5) -> (processor x 5).. 2020. 11. 5.
Spring 4 interceptor custom annotation Spring 4.3 기준으로 Controller 클래스에서 빈과 메소드 단위 custom annotation 설정을 인터셉터에서 체크하는 방법에 대해 알아본다. 1. Custom annotation 생성 import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @Target({ ElementType.METHOD, ElementType.TYPE }) @Retention(RetentionPolicy.RUNTIM.. 2019. 11. 13.
Spring 4 request logging Spring 4 xml 기반 Request 요청에 대한 로깅 설정을 알아본다. 1. spring-context.xml 설정 - includeClientInfo : 요청 클라이언트 정보 - includeHeaders : 요청 전체 헤더값 로깅 - includePayload : 요청 바디값 로깅 - includeQueryString : 요청 파라미터 로깅 - maxPayloadLength : 요청 바디값 로깅 최대길이(너무 크게 잡으면 메모리풀 날 수 있음) 2. web.xml 설정 commonsRequestLoggingFilter org.springframework.web.filter.DelegatingFilterProxy commonsRequestLoggingFilter /* 3. logback.xml .. 2019. 11. 7.