修复:定时任务prod环境,不自动初始化任务问题

This commit is contained in:
ruying408
2024-09-20 23:22:03 +08:00
parent dd023953f5
commit 322330cf1e

View File

@@ -1,11 +1,10 @@
package com.cool.modules.task.event;
import com.cool.core.init.DBFromJsonInit;
import com.cool.modules.task.service.TaskInfoService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.event.EventListener;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;
/**
@@ -14,12 +13,12 @@ import org.springframework.stereotype.Component;
@Slf4j
@Component
@RequiredArgsConstructor
public class TaskEvent {
public class TaskEvent implements ApplicationRunner {
final private TaskInfoService taskInfoService;
@EventListener
public void handleDbInitCompleteEvent(DBFromJsonInit.DbInitCompleteEvent event) {
@Override
public void run(ApplicationArguments args) throws Exception {
taskInfoService.init();
log.info("初始化任务");
}