在服務啓動監聽器裏定時請求,緩存到靜態的變量中,time=7000秒
public class StartupListener extends ContextLoaderListener implements
ServletContextListener {
int time = 7000;
@Override
public void contextInitialized(ServletContextEvent event) {
super.contextInitialized(event);
new Thread(new Runnable() {
public void run() {
while(true){
Param.TOKEN = WeiXinUtil.getToken();
Param.TICKET = WeiXinUtil.getConfig();
System.out.println("token:"+Param.TOKEN.getAccess_token()+" , ticken:"+Param.TICKET);
try {
Thread.sleep(time*1000);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}).start();
}
}