Java Spring @Scheduled tasks executing twice

前端 未结 23 1544
清歌不尽
清歌不尽 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:38

    i am using spring 4.0.3 and i have this problem. i solved it by renaming my beans.

    to:

    
    
    
    

    I noticed some INFO logging saying that no bean named taskScheduler found, creating a new instance. So I figured there were two instance of the taskScheduler.

    Let me know if this works for you too :)

提交回复
热议问题