SpringBoot2.x開發案例之整合Quartz任務管理系統

来源:https://www.cnblogs.com/smallSevens/archive/2018/04/12/8798451.html
-Advertisement-
Play Games

基於spring boot 2.x + quartz 的CRUD任務管理系統,適用於中小項目。 基於spring boot +quartz 的CRUD任務管理系統: https://gitee.com/52itstyle/spring boot quartz 開發環境 JDK1.8、Maven、Ec ...


基於spring-boot 2.x + quartz 的CRUD任務管理系統,適用於中小項目。

基於spring-boot +quartz 的CRUD任務管理系統:

https://gitee.com/52itstyle/spring-boot-quartz

開發環境

JDK1.8、Maven、Eclipse

技術棧

SpringBoot2.0.1、thymeleaf3.0.9、quartz2.3.0、iview、vue、layer、AdminLTE、bootstrap

啟動說明

  • 項目使用的資料庫為MySql,選擇resources/sql中的tables_mysql_innodb.sql文件初始化資料庫信息。
  • 在resources/application.properties文件中替換為自己的數據源。
  • 運行Application main方法啟動項目,項目啟動會自動創建一個測試任務 見:com.itstyle.quartz.config.TaskRunner.java。
  • 項目訪問地址:http://localhost:8080/task

項目截圖






項目源碼: https://gitee.com/52itstyle/spring-boot-task

版本區別(spring-boot 1.x and 2.x)

這裡只是針對這兩個項目異同做比較,當然spring-boot 2.x版本升級還有不少需要註意的地方。

項目名稱配置:

# spring boot 1.x
server.context-path=/quartz
# spring boot 2.x
server.servlet.context-path=/quartz

thymeleaf配置:

#spring boot 1.x
spring.thymeleaf.mode=LEGACYHTML5
#spring boot 2.x
spring.thymeleaf.mode=HTML

Hibernate配置:

# spring boot 2.x JPA 依賴  Hibernate 5
# Hibernate 4 naming strategy fully qualified name. Not supported with Hibernate 5.
spring.jpa.hibernate.naming.strategy = org.hibernate.cfg.ImprovedNamingStrategy
# stripped before adding them to the entity manager)
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
# Hibernate 5
spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyJpaImpl
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl

quartz配置:

# spring boot 2.x 已集成Quartz,無需自己配置
spring.quartz.job-store-type=jdbc
spring.quartz.properties.org.quartz.scheduler.instanceName=clusteredScheduler
spring.quartz.properties.org.quartz.scheduler.instanceId=AUTO
spring.quartz.properties.org.quartz.jobStore.class=org.quartz.impl.jdbcjobstore.JobStoreTX
spring.quartz.properties.org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.StdJDBCDelegate
spring.quartz.properties.org.quartz.jobStore.tablePrefix=QRTZ_
spring.quartz.properties.org.quartz.jobStore.isClustered=true
spring.quartz.properties.org.quartz.jobStore.clusterCheckinInterval=10000
spring.quartz.properties.org.quartz.jobStore.useProperties=false
spring.quartz.properties.org.quartz.threadPool.class=org.quartz.simpl.SimpleThreadPool
spring.quartz.properties.org.quartz.threadPool.threadCount=10
spring.quartz.properties.org.quartz.threadPool.threadPriority=5
spring.quartz.properties.org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread=true

預設首頁配置:

/**
 * 配置首頁 spring boot 1.x
 * 創建者 小柒2012
 * 創建時間 2017年9月7日
 */
@Configuration
public class MyAdapter extends WebMvcConfigurerAdapter{
    @Override
    public void addViewControllers( ViewControllerRegistry registry ) {
        registry.addViewController( "/" ).setViewName( "forward:/login.shtml" );
        registry.setOrder( Ordered.HIGHEST_PRECEDENCE );
        super.addViewControllers( registry );
    } 
}
/**
 * 配置首頁(在SpringBoot2.0及Spring 5.0 WebMvcConfigurerAdapter以被廢棄 
 * 建議實現WebMvcConfigurer介面)
 * 創建者 小柒2012
 * 創建時間  2018年4月10日
 */
@Configuration
public class MyAdapter implements WebMvcConfigurer{
    @Override
    public void addViewControllers( ViewControllerRegistry registry ) {
        registry.addViewController( "/" ).setViewName( "forward:/login.shtml" );
        registry.setOrder( Ordered.HIGHEST_PRECEDENCE );
    } 
}

待解決問題:

/**
     * Set a strategy for handling the query results. This can be used to change
     * "shape" of the query result.
     *
     * @param transformer The transformer to apply
     *
     * @return this (for method chaining)
     *
     * @deprecated (since 5.2)
     * @todo develop a new approach to result transformers
     */
    @Deprecated
    Query<R> setResultTransformer(ResultTransformer transformer);

hibernate 5.2 廢棄了 setResultTransformer,說是要開發一種新的獲取集合方法,顯然目前還沒實現,處於TODO狀態。

項目源碼: https://gitee.com/52itstyle/spring-boot-task


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 官方說明: jQuery.each(object, [callback]) 概述 通用例遍方法,可用於例遍對象和數組。 不同於例遍 jQuery 對象的 $().each() 方法,此方法可用於例遍任何對象。回調函數擁有兩個參數:第一個為對象的成員或數組的索引,第二個為對應變數或內容。如果需要退出 ...
  • 今天做一個小實戰,需要讓一個登錄框始終保持水平和垂直居中,第一個想到的就是通過定位(要想讓一個div居中,採用定位可以解決,示例), 然後開始接觸flex佈局,學完感覺真的好用,現把知識點記錄一下,以便自己日後查看(學習教程:阮大師的教程),筆記開始: 傳統的佈局:圍繞盒子模型(border、mar ...
  • 查看了ueditor.all.js得源代碼發現單圖片上傳是在選擇文件輸入框change事件執行表單Submit,但是出現一個問題請求頭沒有加入Cookie,導致後端身份認證失敗,上傳最終失敗。 ueditor.all.js 24603行原代碼: 後改為了jquery提交form表單,解決了問題, 不 ...
  • [1]cookie認證 [2]token認證 [3]JWT [4]認證介面 ...
  • js編寫流程、數據類型、變數的命名、變數應用、數組、定時器、子節點和父節點、、、、 ...
  • [1]概述 [2]fetch請求 [3]自定義參數 [4]post [5]json數據 [6]檢測成功 [7]Headers [8]封裝 ...
  • 命令模式是我們能夠實現發送者和接收者之間的完全解耦,發送者是調用操作的對象,而接收者是接收請求並執行特定操作的對象。通過解耦,發送者無需瞭解接收者的介面。在這裡,請求的含義是需要被執行的命令。 作用 將一個請求封裝為一個對象,從而使你可用不同的請求對客戶進行參數化;對請求排隊或記錄請求日誌,以及支持 ...
  • 登錄鑒權:1. 用戶名+密碼 登錄請求2. 後臺接收登錄請求,生成ToKen(用戶名/密碼正確) 返回token3. 請求其他api 都帶上token,後臺校驗token是否存在/過期 後臺代碼如下:登錄/登出 @RestController@RequestMappingclass AuthCont ...
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...