Skip to content

Commit 2f7b8f6

Browse files
committed
enable scheduling
1 parent 9a7693a commit 2f7b8f6

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

src/main/java/com/cc/etherscan/io/EtherContractProcessorApplication.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import org.mybatis.spring.annotation.MapperScan;
44
import org.springframework.boot.SpringApplication;
55
import org.springframework.boot.autoconfigure.SpringBootApplication;
6+
import org.springframework.scheduling.annotation.EnableScheduling;
67
import org.springframework.transaction.annotation.EnableTransactionManagement;
78

89
/**
@@ -11,6 +12,7 @@
1112
@SpringBootApplication
1213
@EnableTransactionManagement
1314
@MapperScan("com.cc.etherscan.io.mapper")
15+
@EnableScheduling
1416
public class EtherContractProcessorApplication {
1517

1618
public static void main(String[] args) {

src/main/java/com/cc/etherscan/io/schedule/EtherEumSchedule.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
import com.cc.etherscan.io.processor.EthereumContractProcessor;
55
import org.springframework.beans.factory.annotation.Value;
66
import org.springframework.data.redis.core.RedisTemplate;
7+
import org.springframework.scheduling.annotation.Scheduled;
78
import org.springframework.stereotype.Component;
89
import us.codecraft.webmagic.Spider;
910

10-
import javax.annotation.PostConstruct;
1111
import javax.annotation.Resource;
1212

1313
/**
@@ -38,7 +38,7 @@ public class EtherEumSchedule {
3838
@Value("${etherscan.intervalSeconds}")
3939
private int intervalSeconds = 4;
4040

41-
@PostConstruct
41+
@Scheduled(cron="0 0/2 * * * ?")
4242
public void start() {
4343
for (int i = startPage; i<= totalPage; i++) {
4444
Spider.create(new EthereumContractProcessor(redisTemplate))

src/main/resources/application.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ mybatis-plus:
4040
map-underscore-to-camel-case: true
4141
cache-enabled: false
4242
etherscan:
43-
pageSize: 25
44-
startPage: 10
45-
totalPage: 1560
46-
threadCount: 5
47-
intervalSeconds: 4
43+
pageSize: 10
44+
startPage: 1
45+
totalPage: 1
46+
threadCount: 1
47+
intervalSeconds: 1

0 commit comments

Comments
 (0)