I encountered this issue 2 times. So want to record it.
1 -> component scan and xml bean definition
The 1st time i have this problem is the bean which contains the ‘@Scheduled’ method is annotated with @Component and also registered in the applicationContext.xml. This would make the task being scheduled twice.
2 -> two applicationContext.xml being registered.
The 2nd time I have this is in another project where struts is used. and in the struts config , here is something :
<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn"> <set-property property="contextConfigLocation" value="/WEB-INF/action-servlet.xml,/WEB-INF/applicationContext.xml"/> </plug-in>
Notice the 2nd file, which would register the application context again given the context has been initialized once in the web.xml.