一 在需要实现的类上加注解
1.实现定时任务 @Scheduled(cron = "*/40 * * * * ?") @Configuration @EnableScheduling
二 实现动态定时,需要重写
package pro.tjkj.courseperiphery.config;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.Trigger;
import org.springframework.scheduling.TriggerContext;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.SchedulingConfigurer;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
import org.springframework.scheduling.support.CronTrigger;
import org.springframework.stereotype.Component;
import pro.tjkj.courseperiphery.entity.NoticeEntity;
import pro.tjkj.courseperiphery.mapper.NoticeMapper;
import pro.tjkj.courseperiphery.service.NoticeService;
import pro.tjkj.co