1、启动内引入 启动注解 @EnableScheduling
2、具体功能 上使用注解 information
/**
* 定时更新告警消息和生成新的告警
*/
@Scheduled(cron = "0 0/3 * * * ?")
public void messageInformation() {
long start = System.currentTimeMillis();
tbMessageInfoService.addMessageTask(tbMessageInfoService.updateMessageTask());
long time = System.currentTimeMillis() - start;
System.out.println("操作完成,执行时间:" + time + "毫秒");
}