package com.yingji.quartz; import com.yingji.service.AccidentService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.annotation.Configuration; import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; /** * 120定时任务保存数据 * * @author wu * @since 2024/5/10 上午10:05 */ @Configuration @Transactional(rollbackFor = Exception.class) public class AccidentQuartz { public static final Logger log = LoggerFactory.getLogger(AccidentQuartz.class); @Resource private AccidentService accidentService; @Async @Scheduled(cron = "*/10 * * * * ? ") public void savaData() { String accessToken = accidentService.getAuthorizeToken(); accidentService.getAccidentUrl(accessToken); log.info("=================120定时任务结束==============="); } }