From c7e744a551d930620614f68e4aa9c57f22fabf3e Mon Sep 17 00:00:00 2001 From: JSoi Date: Sun, 31 Jul 2022 20:33:08 +0900 Subject: [PATCH] =?UTF-8?q?#45=20[Add]=20ShedLock=20=EC=B6=94=EA=B0=80,=20?= =?UTF-8?q?TimeZone=20=EC=84=A4=EC=A0=95=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/mpnp/baechelin/BaechelinApplication.java | 8 ++++++++ .../com/mpnp/baechelin/config/SchedulerConfiguration.java | 3 ++- .../com/mpnp/baechelin/store/service/StoreService.java | 6 +++--- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/mpnp/baechelin/BaechelinApplication.java b/src/main/java/com/mpnp/baechelin/BaechelinApplication.java index f8813d3..bd74444 100644 --- a/src/main/java/com/mpnp/baechelin/BaechelinApplication.java +++ b/src/main/java/com/mpnp/baechelin/BaechelinApplication.java @@ -11,6 +11,9 @@ import org.springframework.data.jpa.repository.config.EnableJpaAuditing; import org.springframework.scheduling.annotation.EnableScheduling; +import javax.annotation.PostConstruct; +import java.util.TimeZone; + @EnableJpaAuditing @EnableConfigurationProperties({ @@ -25,4 +28,9 @@ public class BaechelinApplication { public static void main(String[] args) { SpringApplication.run(BaechelinApplication.class, args); } + @PostConstruct + public void started() { + // timezone UTC 셋팅 + TimeZone.setDefault(TimeZone.getTimeZone("Asia/Seoul")); + } } \ No newline at end of file diff --git a/src/main/java/com/mpnp/baechelin/config/SchedulerConfiguration.java b/src/main/java/com/mpnp/baechelin/config/SchedulerConfiguration.java index f459744..d932f60 100644 --- a/src/main/java/com/mpnp/baechelin/config/SchedulerConfiguration.java +++ b/src/main/java/com/mpnp/baechelin/config/SchedulerConfiguration.java @@ -7,6 +7,7 @@ import net.javacrumbs.shedlock.provider.jdbctemplate.JdbcTemplateLockProvider; import javax.sql.DataSource; +import java.util.TimeZone; @Configuration @@ -16,7 +17,7 @@ public LockProvider lockProvider(DataSource dataSource) { return new JdbcTemplateLockProvider( JdbcTemplateLockProvider.Configuration.builder() .withJdbcTemplate(new JdbcTemplate(dataSource)) - .usingDbTime() + .withTimeZone(TimeZone.getTimeZone("Asia/Seoul")) .build() ); } diff --git a/src/main/java/com/mpnp/baechelin/store/service/StoreService.java b/src/main/java/com/mpnp/baechelin/store/service/StoreService.java index a1f8c53..4adc3b8 100644 --- a/src/main/java/com/mpnp/baechelin/store/service/StoreService.java +++ b/src/main/java/com/mpnp/baechelin/store/service/StoreService.java @@ -231,10 +231,10 @@ public List searchStores(String sido, String sigungu, Stri return result; } - @Scheduled(cron = "0 0 0-23 * * *") - @SchedulerLock(name = "updateScheduler", - lockAtLeastFor = "PT30M", lockAtMostFor = "PT59M") + @Scheduled(cron = "0 0 0-23 * * *") // 1시간에 한 번 + @SchedulerLock(name = "updateScheduler", lockAtLeastFor = "PT58M", lockAtMostFor = "PT30M") public void updateSchedule() { + log.info("AVG, BOOKMARK COUNT SCHEDULING"); List storeList = storeRepository.findAll(); for (Store store : storeList) { if (!store.getReviewList().isEmpty()) {