@Component public class ScheduledTask { private final Logger logger = LoggerFactory.getLogger(getClass()); @Autowired private ProductService productService; @Autowired private RedisService redisService; @Autowired StatisticsService statisticsService; @Autowired StatiscsAllService statiscsAllService; /** * 每间隔10秒输出时间 * */ // @Scheduled(fixedRate = 10000) @Scheduled(cron="0 0 3 * * ?") //每天三点执行 public void logTime() { logger.info("定时任务开始,现在时间:" + System.currentTimeMillis()); // productService.initTop7(); // productService.initLastUpdate12(); // productService.initHot12(); // productService.initHotWorks12(); //统计数据 statisticsService.saveToDB(); statiscsAllService.saveToDB(); logger.info("定时任务结束,现在时间:" + System.currentTimeMillis()); } }