I am creating an @Scheduled task to run every 5 seconds. As has been a problem in other questions, my task is running twice!
I have looked at other ques
I believe this is caused by same config file being loaded twice in your web.xml
servlet
org.springframework.web.servlet.DispatcherServlet
contextConfigLocation
/WEB-INF/spring_config.xml
1
contextConfigLocation
/WEB-INF/spring_config.xml
EDIT To fix it:
Create another file servlet-servlet.xml (this will be picked up by the ServletDispatcher config by default since it matches the file by servlet name) The file will contain this:
Modify the original file (spring-config.xml):
Modify your web xml servlet config to following:
servlet
org.springframework.web.servlet.DispatcherServlet
1