Upgrading to springframework.scheduling.concurrent?

前端 未结 3 1402
谎友^
谎友^ 2021-02-07 11:37

As of Spring 3.0 the ScheduledTimerTask is deprecated and I can\'t understand how to upgrade to org.springframework.scheduling.concurrent.

    

        
3条回答
  •  无人共我
    2021-02-07 12:12

    Use org.springframework.scheduling.concurrent.ScheduledExecutorFactoryBean in place of org.springframework.scheduling.timer.TimerFactoryBean and use org.springframework.scheduling.concurrent.ScheduledExecutorTask in place of org.springframework.scheduling.timer.ScheduledTimerTask. You will need to adjust the property names and values as needed but, that should be pretty self evident.

    Optionally, you could refactor your com.example.OnlineTimerTask to not extend java.util.TimeTask as the ScheduledTimerTask only requires a runnable.

提交回复
热议问题