SpringBoot - Springdoc (swagger) 버전 호환표
·
Spring
이거 버전 잘못맞추면 좀 귀찮아가지고 정리함 Spring Boot 버전springdoc-openapi 권장/호환 버전3.5.x2.8.x3.4.x2.7.x ~ 2.8.x3.3.x2.6.x3.2.x2.3.x ~ 2.5.x3.1.x2.2.x3.0.x2.0.x ~ 2.1.x2.7.x, 1.5.x1.6.0 이상2.6.x, 1.5.x1.6.0 이상2.5.x, 1.5.x1.5.9 이상2.4.x, 1.5.x1.5.0 이상2.3.x, 1.5.x1.4.0 이상2.2.x, 1.5.x1.2.1 이상2.0.x, 1.5.x1.0.0 이상 자세한 정보는 하위 링크 참고https://springdoc.org/faq.html#_what_is_the_compatibility_matrix_of_springdoc_openapi_with_s..
[SpringBoot] 메세지 큐 Consumer 역할 코드 샘플
·
Spring
spring: kafka: consumer: # 수동 커밋 사용 (처리 완료 후 명시적으로 커밋) enable-auto-commit: false group-id: product-order-group bootstrap-servers: localhost:9092app: kafka: topic: main: product-order-topic dlq: product-order-topic.dlt # DLT 토픽은 Spring이 .dlt 접미사로 자동 생성 // IdempotentService.java@Servicepublic class IdempotentService { // 멱등성 키를 저장하는 영구 저장소 (운영 시 Redi..
API 공통 응답 객체 만들어보기
·
Spring
API 호출에 대한 공통 응답 객체를 만들어보자 일단 여기서는 JSend를 참고하고 좀 더 간소화해서 만들었다 1. 성공 시 JSON { "status": "success", "body": { "exampleKey": "exampleValue" } } 2. 실패 시 JSON { "status": "error", "errorMessage": "API 실패 메세지" } 1. 정의된 API Response에 맞는 응답객체 만들기 2. ExceptionHandler를 통해 에러 발생시 실패 응답 생성 3. ResponseBodyAdvice를 사용해 성공 / 실패 시 응답 객체 생성 ErrorResponse 객체를 따로 둔 이유는 위의 예제에서는 그냥 이 글을 쓰기 위해서 errorMessage 하나만을 뒀지만,..
@Value / @ConfigurationProperties 사용해보기
·
Spring
application.yml 에 값을 세팅하고 불러와보자 custom-property: person: first-name: "John" last-name: "Doe" age: 99 etc: etc1: "추가정보1" etc2: "추가정보2" etc3: 1234 @Value @Slf4j @Component public class ExternalPropertiesV1 implements ApplicationRunner { @Value("${custom-property.person.first-name}") private String firstName; @Value("${custom-property.person.last-name}") private String lastName; @Value("${custom-pr..
[Spring Batch] 공부 내용 정리 (2)
·
Spring
Batch 실행방식 종류, 특징 정리 1. OS 스케줄러 이용 한 머신 내부에서 스케줄러를 통해 Batch 프로그램을 실행 ex) 리눅스 crontab 실행 결과를 log 파일을 남겨 확인한다 확인이 어렵고 많은 Job을 처리하긴 어렵지만 간단한 배치프로그램을 돌려보길 원한다면 사용해볼만 하다 2. Quartz Scheduler 이용 Quartz + Spring Batch 프레임워크를 함께 사용해 어플리케이션을 개발한다 어플리케이션 내부에서 스케줄링하므로 Batch 실행이 빠르다 스케줄링 데이터가 DB에 저장되어 Admin을 따로 만들어야 한다 3. CI 프로그램 이용 마스터 슬레이브로 명령을 전달해 배치 프로그램을 실행시킨다 ex) 젠킨스(Jenkins) 젠킨스에서 지원하는 스케줄링 기능을 통해 배치 ..
[Spring Batch] 공부 내용 정리 (1)
·
Spring
https://docs.spring.io/spring-batch/docs/current/reference/html/index-single.html#spring-batch-intro Spring Batch - Reference Documentation If a group of Steps share similar configurations, then it may be helpful to define a "parent" Step from which the concrete Steps may inherit properties. Similar to class inheritance in Java, the "child" Step combines its elements and attributes with the pa d..