0
嗨我是Spring框架本身的新手,我正在實現Spring調度框架。我寫了我的類和方法來執行。Spring調度框架
現在我所做的只是添加下面的代碼,spring.xml
<bean id="schedulerInstance" class="com.package.SchedulerService">
<property name="maxAgeTableOne" value="30"/>
<property name="maxAgeTableTwo" value="30"/>
<property name="maxAgeTableThree" value="30"/>
</bean>
<task:scheduled-tasks scheduler="taskScheduler">
<!-- An interval-based trigger where the interval is measured from the completion time of the previous task. -->
<task:scheduled ref="schedulerInstance" method="cleanuptableone" cron="0 0 23 1 * ? " />
<task:scheduled ref="schedulerInstance" method="cleanuptabletwo" cron="0 0 23 1 * ? "/>
<task:scheduled ref="schedulerInstance" method="cleanuptablethree" cron="0 0 23 1 * ? " />
</task:scheduled-tasks>
<!-- Defines a ThreadPoolTaskScheduler instance with configurable pool size. -->
<task:scheduler id="taskScheduler" pool-size="1"/>
從我認爲它現在計劃每月運行,但它似乎沒有工作或運行的任何事情?有什麼我應該做的嗎?
上面的SchedulerService類是純java類,沒有任何彈簧相關或調度相關的東西。
請指導我還應該做些什麼來使課程成爲預定課程。
感謝, SS
因此,即使我改變了每分鐘運行的cron作業的頻率,我在日誌中沒有看到任何內容,但我還是有全部的日誌語句。我是否應該使用@Scheduled之類的任何註釋,以便春天知道特定計劃會運行?謝謝。 –
單元測試(Junit)運行正常,出現問題。 –
你是如何運行這個代碼的,從主或部署到tomcat或同等的?如果來自主,什麼代碼加載春天上下文?如果來自tomcat,您是否使用ContextLoadListener進行初始化? – cmutt78