1 code
2.接下來的在spring 裡配置:package util;
import org.apache.log4j.*;
public class taskjob catch (exception e)
}}
<?xml version="1.0" encoding="utf-8"?>
sayhello
0 * 08-21 * * ?
3.測試執行的類,只要把spring的配置檔案載入了就可以看到定時任務執行了。
package util;
public static void main(string args)
}
如果要在web專案中執行的話還要在web.xml 中加入如下**:
contextconfiglocation
log4jconfiglocation
/web-inf/log4j.properties
org.springframework.web.context.contextloaderlistener
Spring定時任務的簡單例子
這幾天因為工作的需要,用到了spring的定時任務的功能,網上查資料,並且實際運用了一下,覺得spring還是很智慧型化的,只需要配置一下配置檔案就可以了,下面的這篇文章我覺得還是很好的,摘錄下來,供以後參考用 package util import org.apache.log4j.public ...
Spring定時任務的簡單例子
定時任務類package util import org.apache.log4j.public class taskjob catch exception e 在spring中需要以下配置 sayhello 0 08 21 在web專案中執行的話還要在web.xml 中加入如下 contextco...
Spring定時任務的簡單例子
需要匯入quartz all 1.6.1 rc1.jar import org.apache.log4j.public class taskjob catch exception e 2 接下來的在spring 裡配置 class org.springframework.scheduling.qua...