springBoot 实现定时任务
今天有一个需求:使用定时任务实现对数据的更新
重点
- mybaits-plus 实现对数据的更新
- spring boot 的定时任务的实现
实现逻辑
- 链接数据库
- mybaits-plus 反向生成 CRUD 接口
- 书写
service
层对数据批量更新的service
spring boot
定时任务的书写- 代码测试
代码实现
这里省略了1和2,3的步骤,直接从4开始
package com.sun.tast;
import com.sun.service.ITimeService;
import com.sun.service.impl.CronServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.SchedulingConfigurer;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
import org.springframework.