Java Spring @Scheduled tasks executing twice

前端 未结 23 1674
清歌不尽
清歌不尽 2020-11-29 09:07

I have a simple test method here that is set to run every 5 seconds and it does, but looking at the System.out you can see it appears to be doing something odd.



        
23条回答
  •  庸人自扰
    2020-11-29 09:32

    I had this same problem, and I eventually found out that the problem was occurring as a result of the beans being created in the root context as well as the servlet context.

    So, to fix this, you need to separate the creation of the beans into the appropriate contexts.

    This answer explains really well how to that and was what fixed my problem.

提交回复
热议问题