資源簡介
但如果只是簡單的跑個任務其實spring升級到3后已經自帶任務調度器了,相比之下Spring task無論是理解還是使用都簡單很多。但是Quartz有線程和線程管理以及集群等高級特性,所以大家可以自行選擇了。不過一般情況下,覺得SpringTask足夠了。
Spring Task提供兩種方式進行配置,注解和配置文件。使用注解雖然簡單,不用配置xml,但是相對于修改比較頻繁的任務來說,打包編譯的過程也是挺麻煩的,建議使用配置文件實現。

代碼片段和文件信息
package?task;
import?org.springframework.scheduling.annotation.Scheduled;
import?org.springframework.stereotype.Component;
/**
?*?任務測試?科幫網?http://www.52itstyle.com/
?*?創建者 張志朋
?*?創建時間 2016年7月15日
?*
?*/
@Component(“TestJob“)??
public?class?TestJob?{
@Scheduled(cron?=?“0/5?*?*?*?*??“)//每隔1秒隔行一次?
????public?void?test1()
????{
????????System.out.println(“job1?開始執行“);
????}?
@Scheduled(cron?=?“0/5?*?*?*?*??“)//每隔1秒隔行一次?
????public?void?test2()
????{
????????System.out.println(“job2?開始執行“);
????}?
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????3847??2016-07-13?16:06??.classpath
?????文件????????1049??2016-07-13?16:03??.project
?????目錄???????????0??2016-07-15?11:16??.settings\
?????文件?????????500??2016-07-13?16:03??.settings\.jsdtscope
?????文件?????????670??2016-07-13?16:05??.settings\org.eclipse.jdt.core.prefs
?????文件?????????659??2016-07-13?16:04??.settings\org.eclipse.wst.common.component
?????文件?????????305??2016-07-13?16:03??.settings\org.eclipse.wst.common.project.facet.core.xm
?????文件??????????49??2016-07-13?16:03??.settings\org.eclipse.wst.jsdt.ui.superType.container
?????文件???????????6??2016-07-13?16:03??.settings\org.eclipse.wst.jsdt.ui.superType.name
?????目錄???????????0??2016-07-15?11:16??build\
?????目錄???????????0??2016-07-15?11:16??build\classes\
?????文件????????1905??2016-07-15?11:08??build\classes\spring-context.xm
?????目錄???????????0??2016-07-15?11:16??build\classes\task\
?????文件?????????808??2016-07-15?11:12??build\classes\task\TestJob.class
?????目錄???????????0??2016-07-15?11:16??src\
?????目錄???????????0??2016-07-15?11:16??src\java\
?????目錄???????????0??2016-07-15?11:16??src\java\task\
?????文件?????????609??2016-07-15?11:12??src\java\task\TestJob.java
?????目錄???????????0??2016-07-15?11:16??src\resource\
?????文件????????1905??2016-07-15?11:08??src\resource\spring-context.xm
?????目錄???????????0??2016-07-15?11:16??WebRoot\
?????目錄???????????0??2016-07-15?11:16??WebRoot\me
?????文件??????????39??2016-07-13?16:03??WebRoot\me
?????目錄???????????0??2016-07-15?11:16??WebRoot\WEB-INF\
?????目錄???????????0??2016-07-15?11:16??WebRoot\WEB-INF\lib\
?????文件????????4467??2016-07-13?14:34??WebRoot\WEB-INF\lib\aopalliance-1.0.jar
?????文件??????188671??2016-03-04?12:49??WebRoot\WEB-INF\lib\commons-beanutils.jar
?????文件??????559366??2016-03-04?12:49??WebRoot\WEB-INF\lib\commons-collections-3.1.jar
?????文件???????57779??2016-03-04?12:49??WebRoot\WEB-INF\lib\commons-fileupload-1.2.1.jar
?????文件???????87776??2016-03-04?12:49??WebRoot\WEB-INF\lib\commons-io-1.3.2.jar
?????文件??????243016??2016-03-04?12:49??WebRoot\WEB-INF\lib\commons-lang.jar
............此處省略34個文件信息
- 上一篇:網上商城項目源碼
- 下一篇:電子商務設計師歷年試題及答案真題2009-2016
評論
共有 條評論