我看到有一些类似的问题;但他们中的大多数人都有重复的 bean 导致这个问题。尽管我的应用程序上下文定义中没有重复配置,但我的计划计时器也执行了两次。
这是我在applicationContext.xml
. 刚刚启用注释驱动的任务。
<task:annotation-driven />
这是我的计时器服务:
@Component
public class SessionTimer {
@Scheduled(fixedDelay = 30000)
public void killSession() {
// business processes
logger.debug("Current time: " + RIAUtil.sdfTimestampWithSeconds.format(now));
}
}
这个问题背后有什么想法吗?