- spring中Scheduled定时注解的使用
@Scheduled(fixedDelay = 1000 * 7000)
public void getAccessTokenJob_hsfc() {
accessToken = GetToken.getAccessToken(appid, appsecret);
logger.info("Excute accessTokenJob_hsfc(),accessToken:"
+ accessToken.toString());
}
- 到spring-mvc配置中加入以下配置
<!-- 设置定时任务 -->
<task:annotation-driven/>
<!-- 顶部加入配置-->
xmlns:task="http://www.springframework.org/schema/task"
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.1.xsd