日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > windows >内容正文

windows

SpringBoot2.x开发案例之整合Quartz任务管理系统

發布時間:2023/12/20 windows 21 豆豆
生活随笔 收集整理的這篇文章主要介紹了 SpringBoot2.x开发案例之整合Quartz任务管理系统 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

基于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{@Overridepublic 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{@Overridepublic 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*/@DeprecatedQuery<R> setResultTransformer(ResultTransformer transformer); 復制代碼

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

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

總結

以上是生活随笔為你收集整理的SpringBoot2.x开发案例之整合Quartz任务管理系统的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。