This commit is contained in:
xxy
2019-12-12 21:56:39 +08:00
parent 72d733b8fb
commit 6b59b7b899
2 changed files with 13 additions and 12 deletions

View File

@ -23,18 +23,19 @@ public class StartListener implements ApplicationListener<ContextRefreshedEvent>
@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
log.info("程序启动");
crawlBook();
new Thread(()->{
while (true) {
try {
log.info("crawlBooks执行中。。。。。。。。。。。。");
crawlSource.parse();
Thread.sleep(1000 * 60 * 5);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
}).start();
}
private void crawlBook() {
new Timer().schedule(new TimerTask() {
@Override
public void run() {
log.debug("crawlBooks执行中。。。。。。。。。。。。");
crawlSource.parse();
crawlBook();
}
},1000*60*5);
}
}