增加定时任务,每5分钟请求一下接口,确保会话不过期
This commit is contained in:
parent
08124d17e7
commit
fa8b890e26
|
@ -8,11 +8,13 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
||||
import org.springframework.boot.web.servlet.ServletRegistrationBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableScheduling
|
||||
public class WebdavTeambitionApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
package com.github.zxbu.webdavteambition.config;
|
||||
|
||||
import com.github.zxbu.webdavteambition.model.result.TFile;
|
||||
import com.github.zxbu.webdavteambition.store.AliYunDriverClientService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class AliYunDriverCronTask {
|
||||
|
||||
@Autowired
|
||||
private AliYunDriverClientService aliYunDriverClientService;
|
||||
|
||||
/**
|
||||
* 每隔5分钟请求一下接口,保证token不过期
|
||||
*/
|
||||
@Scheduled(initialDelay = 30 * 1000, fixedDelay = 5 * 60 * 1000)
|
||||
public void refreshToken() {
|
||||
try {
|
||||
TFile root = aliYunDriverClientService.getTFileByPath("/");
|
||||
aliYunDriverClientService.getTFiles(root.getFile_id());
|
||||
} catch (Exception e) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue