@Configuration
@EnableScheduling
@ComponentScan("com.***.timingTask") //扫描路径
public class TimingTaskConfig {
}

==============================================
该路径下的组件
@Component
public class TimingTask {
@Scheduled(cron = "0/5 * * * * ? ") // 间隔5秒执行
public void taskCycle() {
System.out.println("定时任务5秒");
}
}