mirror of
https://github.com/201206030/novel.git
synced 2025-04-27 07:30:50 +00:00
fixed bug
This commit is contained in:
parent
bd19c0733f
commit
72d733b8fb
@ -1,12 +1,18 @@
|
||||
package xyz.zinglizingli.common.listener;
|
||||
|
||||
import com.sun.javafx.tk.Toolkit;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.context.event.ContextRefreshedEvent;
|
||||
import org.springframework.scheduling.TaskScheduler;
|
||||
import org.springframework.scheduling.config.Task;
|
||||
import org.springframework.stereotype.Component;
|
||||
import xyz.zinglizingli.common.crawl.BaseCrawlSource;
|
||||
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@ -17,19 +23,18 @@ public class StartListener implements ApplicationListener<ContextRefreshedEvent>
|
||||
@Override
|
||||
public void onApplicationEvent(ContextRefreshedEvent event) {
|
||||
log.info("程序启动");
|
||||
crawlBook();
|
||||
}
|
||||
|
||||
|
||||
while (true) {
|
||||
try {
|
||||
private void crawlBook() {
|
||||
new Timer().schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
log.debug("crawlBooks执行中。。。。。。。。。。。。");
|
||||
crawlSource.parse();
|
||||
Thread.sleep(1000 * 60 * 5);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
crawlBook();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
},1000*60*5);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user