打印结果:
1480425640001
1480425640001
1480425650000
1480425650000
1480425660001
1480425660001
每十秒钟执行一次,每次都是两遍;代码如下:
application.xml文件,
web.xml
contextConfigLocation classpath:applicationContext.xml Log4jConfigLocation classpath:log4j.properties webAppRootKey user.root Dispatcher org.springframework.web.servlet.DispatcherServlet contextConfigLocation classpath:applicationContext-mvc.xml Dispatcher ***
应该是你的任务在spring容器里面注册了两次
(spring有父子容器之分,context 和 mvc 两个)
从现象来看,applicationContext-mvc.xml文件扫描的范围去掉 你的任务相关的类,问题就可以解决