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
  • 示例項目結構 在 Visual Studio 中創建一個 WinForms 應用程式後,項目結構如下所示: MyWinFormsApp/ │ ├───Properties/ │ └───Settings.settings │ ├───bin/ │ ├───Debug/ │ └───Release/ ...
  • [STAThread] 特性用於需要與 COM 組件交互的應用程式,尤其是依賴單線程模型(如 Windows Forms 應用程式)的組件。在 STA 模式下,線程擁有自己的消息迴圈,這對於處理用戶界面和某些 COM 組件是必要的。 [STAThread] static void Main(stri ...
  • 在WinForm中使用全局異常捕獲處理 在WinForm應用程式中,全局異常捕獲是確保程式穩定性的關鍵。通過在Program類的Main方法中設置全局異常處理,可以有效地捕獲並處理未預見的異常,從而避免程式崩潰。 註冊全局異常事件 [STAThread] static void Main() { / ...
  • 前言 給大家推薦一款開源的 Winform 控制項庫,可以幫助我們開發更加美觀、漂亮的 WinForm 界面。 項目介紹 SunnyUI.NET 是一個基於 .NET Framework 4.0+、.NET 6、.NET 7 和 .NET 8 的 WinForm 開源控制項庫,同時也提供了工具類庫、擴展 ...
  • 說明 該文章是屬於OverallAuth2.0系列文章,每周更新一篇該系列文章(從0到1完成系統開發)。 該系統文章,我會儘量說的非常詳細,做到不管新手、老手都能看懂。 說明:OverallAuth2.0 是一個簡單、易懂、功能強大的許可權+可視化流程管理系統。 有興趣的朋友,請關註我吧(*^▽^*) ...
  • 一、下載安裝 1.下載git 必須先下載並安裝git,再TortoiseGit下載安裝 git安裝參考教程:https://blog.csdn.net/mukes/article/details/115693833 2.TortoiseGit下載與安裝 TortoiseGit,Git客戶端,32/6 ...
  • 前言 在項目開發過程中,理解數據結構和演算法如同掌握蓋房子的秘訣。演算法不僅能幫助我們編寫高效、優質的代碼,還能解決項目中遇到的各種難題。 給大家推薦一個支持C#的開源免費、新手友好的數據結構與演算法入門教程:Hello演算法。 項目介紹 《Hello Algo》是一本開源免費、新手友好的數據結構與演算法入門 ...
  • 1.生成單個Proto.bat內容 @rem Copyright 2016, Google Inc. @rem All rights reserved. @rem @rem Redistribution and use in source and binary forms, with or with ...
  • 一:背景 1. 講故事 前段時間有位朋友找到我,說他的窗體程式在客戶這邊出現了卡死,讓我幫忙看下怎麼回事?dump也生成了,既然有dump了那就上 windbg 分析吧。 二:WinDbg 分析 1. 為什麼會卡死 窗體程式的卡死,入口門檻很低,後續往下分析就不一定了,不管怎麼說先用 !clrsta ...
  • 前言 人工智慧時代,人臉識別技術已成為安全驗證、身份識別和用戶交互的關鍵工具。 給大家推薦一款.NET 開源提供了強大的人臉識別 API,工具不僅易於集成,還具備高效處理能力。 本文將介紹一款如何利用這些API,為我們的項目添加智能識別的亮點。 項目介紹 GitHub 上擁有 1.2k 星標的 C# ...