From 03052548a9abe26e81fd31a32a412e973716c369 Mon Sep 17 00:00:00 2001 From: Songyi Kim <52441906+songyi00@users.noreply.github.com> Date: Wed, 6 Nov 2024 00:21:02 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EC=8A=A4=EC=BC=80=EC=A4=84=EB=9F=AC=20?= =?UTF-8?q?=EC=9E=A1=20=EC=8B=A4=ED=96=89=EC=8B=9C=20=EC=8A=A4=ED=94=84?= =?UTF-8?q?=EB=A7=81=20=EC=BB=A8=ED=85=8D=EC=8A=A4=ED=8A=B8=20=EB=82=B4?= =?UTF-8?q?=EC=97=90=EC=84=9C=20=EC=B0=BE=EB=8F=84=EB=A1=9D=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=20(#87)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: Job 실행시 spring context에 존재하는 빈으로 등록된 잡 사용하도록 변경 * fix: 임시 배포 * feat: 6시간 단위 스케줄링으로 조정 * chore: 불필요한 코드 제거 --- .github/workflows/cd.yml | 1 - .../nexters/goalpanzi/schedule/SchedulerConfig.java | 9 ++------- .../goalpanzi/schedule/SchedulerFactoryConfig.java | 13 ++++++++++++- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index d72eba4c..66d9f125 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -5,7 +5,6 @@ on: branches: - main - develop - - fix/#82-fix-mission-status jobs: build-and-push: diff --git a/src/main/java/com/nexters/goalpanzi/schedule/SchedulerConfig.java b/src/main/java/com/nexters/goalpanzi/schedule/SchedulerConfig.java index 7214c55d..a27b8ed1 100644 --- a/src/main/java/com/nexters/goalpanzi/schedule/SchedulerConfig.java +++ b/src/main/java/com/nexters/goalpanzi/schedule/SchedulerConfig.java @@ -6,18 +6,13 @@ import org.quartz.JobDetail; import org.quartz.Scheduler; import org.quartz.SchedulerException; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Lazy; -import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; -import org.springframework.scheduling.quartz.SchedulerFactoryBean; -import org.springframework.stereotype.Component; +import org.springframework.context.annotation.Configuration; import java.util.List; @Slf4j @RequiredArgsConstructor -@Component +@Configuration public class SchedulerConfig { private final Scheduler scheduler; private final List jobList; diff --git a/src/main/java/com/nexters/goalpanzi/schedule/SchedulerFactoryConfig.java b/src/main/java/com/nexters/goalpanzi/schedule/SchedulerFactoryConfig.java index de819c8f..ddd595b7 100644 --- a/src/main/java/com/nexters/goalpanzi/schedule/SchedulerFactoryConfig.java +++ b/src/main/java/com/nexters/goalpanzi/schedule/SchedulerFactoryConfig.java @@ -1,10 +1,12 @@ package com.nexters.goalpanzi.schedule; import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.scheduling.quartz.SchedulerFactoryBean; +import org.springframework.scheduling.quartz.SpringBeanJobFactory; @Configuration public class SchedulerFactoryConfig { @@ -21,12 +23,21 @@ public ThreadPoolTaskExecutor executor() { return executor; } + @Bean + public SpringBeanJobFactory jobFactory(ApplicationContext ctx) { + SpringBeanJobFactory springBeanJobFactory = new SpringBeanJobFactory(); + springBeanJobFactory.setApplicationContext(ctx); + return springBeanJobFactory; + } + @Bean public SchedulerFactoryBean schedulerFactory( - @Qualifier(SCHEDULER_THREAD_POOL_EXECUTOR) ThreadPoolTaskExecutor threadPoolTaskExecutor + @Qualifier(SCHEDULER_THREAD_POOL_EXECUTOR) ThreadPoolTaskExecutor threadPoolTaskExecutor, + SpringBeanJobFactory jobFactory ) { SchedulerFactoryBean factory = new SchedulerFactoryBean(); factory.setTaskExecutor(threadPoolTaskExecutor); + factory.setJobFactory(jobFactory); return factory; } }