基于spring-boot 2.x + quartz 的CRUD任务管理系统,适用于中小项目。

开发环境

JDK1.8、Maven、Eclipse

技术栈

SpringBoot 2.0.1、thymeleaf 3.0.9、quartz 2.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/quartz

项目名称配置:

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

thymeleaf配置:

#spring boot 1.xspring.thymeleaf.mode=LEGACYHTML5#spring boot 2.xspring.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 5spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyJpaImplspring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl

quartz配置:

# spring boot 2.x 已集成Quartz,无需自己配置spring.quartz.job-store-type=jdbcspring.quartz.properties.org.quartz.scheduler.instanceName=clusteredSchedulerspring.quartz.properties.org.quartz.scheduler.instanceId=AUTOspring.quartz.properties.org.quartz.jobStore.class=org.quartz.impl.jdbcjobstore.JobStoreTXspring.quartz.properties.org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.StdJDBCDelegatespring.quartz.properties.org.quartz.jobStore.tablePrefix=QRTZ_spring.quartz.properties.org.quartz.jobStore.isClustered=truespring.quartz.properties.org.quartz.jobStore.clusterCheckinInterval=10000spring.quartz.properties.org.quartz.jobStore.useProperties=falsespring.quartz.properties.org.quartz.threadPool.class=org.quartz.simpl.SimpleThreadPoolspring.quartz.properties.org.quartz.threadPool.threadCount=10spring.quartz.properties.org.quartz.threadPool.threadPriority=5spring.quartz.properties.org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread=true

默认首页配置:

/** * 配置首页 spring boot 1.x * 创建者 小柒2012 * 创建时间2017年9月7日 */@Configurationpublic 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日 */@Configurationpublic 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 */@DeprecatedQuery setResultTransformer(ResultTransformer transformer);

hibernate 5.2 废弃了 setResultTransformer,说是要开发一种新的获取集合方法,显然目前还没实现,处于TODO状态。

项目截图

集群测试

打开quartz集群配置:

# 打开集群配置spring.quartz.properties.org.quartz.jobStore.isClustered:true# 设置集群检查间隔20sspring.quartz.properties.org.quartz.jobStore.clusterCheckinInterval = 2000 

本地跑两个项目,分别设置不同的端口8081和8082,启动成功以后,会发现只有一个任务在跑,然后杀掉在跑的任务,你会发现另一个项目会检测到集群中的一个任务挂了,然后接管任务。

2018-04-12 09:00:01.792 INFO 7488 --- [_ClusterManager] o.s.s.quartz.LocalDataSourceJobStore : ClusterManager: detected 1 failed or restarted instances.2018-04-12 09:00:01.793 INFO 7488 --- [_ClusterManager] o.s.s.quartz.LocalDataSourceJobStore : ClusterManager: Scanning for instance "itstyle-PC1523496348539"'s failed in-progress jobs.2018-04-12 09:00:01.839 INFO 7488 --- [_ClusterManager] o.s.s.quartz.LocalDataSourceJobStore : ClusterManager: ......Freed 1 acquired trigger(s).大吉大利、今晚吃鸡-01大吉大利、今晚吃鸡-01

扩展

Quartz API核心接口有:

  • Scheduler – 与scheduler交互的主要API;
  • Job – 你通过scheduler执行任务,你的任务类需要实现的接口;
  • JobDetail – 定义Job的实例;
  • Trigger – 触发Job的执行;
  • JobBuilder – 定义和创建JobDetail实例的接口;
  • TriggerBuilder – 定义和创建Trigger实例的接口;

项目地址

  • 基于spring-boot 2.x + quartz 的CRUD任务管理系统:https://gitee.com/52itstyle/spring-boot-task
  • 基于spring-boot 1.x + quartz 的CRUD任务管理系统:https://gitee.com/52itstyle/spring-boot-quartz

quartz配置_基于spring-boot 2.x +quartz 的CRUD任务管理系统相关推荐

  1. c# 基于layui的通用后台管理系统_基于spring boot和vuejs的通用后台管理系统脚手架 guns-lite...

    Guns-lite 前言 guns-lite是在guns的基础上将数据库层由mybatis替换为spring data jpa的系统. guns-lite是一个基于spring boot的后台管理系统 ...

  2. exchange邮件服务器_基于Spring Boot快速实现发送邮件功能

    邮件在项目中经常会被用到,比如用邮件发送通知.比如,通过邮件注册.认证.找回密码.系统报警通知.报表信息等.本篇文章带大家通过SpringBoot快速实现一个发送邮件的功能. 邮件协议 下面先简单了解 ...

  3. springboot2 使用hikaridatasource 并测试_基于Spring Boot 2.x的后端管理网站脚手,源码免费分享...

    基于Spring Boot 2.x 的 Material Design 的后端管理网站脚手架 :提供权限认证 用户管理 菜单管理 操作日志 等常用功能 去繁就简 重新出发 基于Spring Boot ...

  4. java图片加水印上传工具类_基于Spring Boot实现图片上传/加水印一把梭操作

    文章共537字,阅读大约需要 2分钟 ! 概述 很多网站的图片为了版权考虑都加有水印,尤其是那些图片类网站.自己正好最近和图片打交道比较多,因此就探索了一番基于 Spring Boot这把利器来实现从 ...

  5. 项目_功能模块_基于Spring Boot的文件上传下载功能的设计与实现

    文章目录 基于Spring Boot的文件上传下载功能模块的设计与实现 1.前言 2.技术栈 3.关键源码 4.实现效果 4.1.登录 4.2.文件列表 4.3.上传文件测试 4.3.1.测试图片 4 ...

  6. springboot 打卡功能_基于spring boot框架的公司考勤系统的研究与设计

    基于 spring boot 框架的公司考勤系统的研究与设计 李宏坤 ; 郑光勇 ; 谢舞 ; 彭承辉 [期刊名称] <电脑知识与技术> [年 ( 卷 ), 期] 2019(015)018 ...

  7. java spring上传图片_基于Spring Boot实现图片上传/加水印一把梭操作

    文章共 537字,阅读大约需要 2分钟 ! 概述 很多网站的图片为了版权考虑都加有水印,尤其是那些图片类网站.自己正好最近和图片打交道比较多,因此就探索了一番基于 Spring Boot这把利器来实现 ...

  8. boot spring 接口接收数据_基于 Spring Boot 实现 Restful 风格接口,实现增删改查功能...

    优质文章,及时送达 Spring Boot介绍 Spring Boot是由Pivotal团队提供的全新框架,其设计目的是用来简化新Spring应用的初始搭建以及开发过程.该框架使用了特定的方式来进行配 ...

  9. springboot jwt token前后端分离_基于Spring Boot+Spring Security+JWT+Vue前后端分离的开源项目...

    一.前言 最近整合Spring Boot+Spring Security+JWT+Vue 完成了一套前后端分离的基础项目,这里把它开源出来分享给有需要的小伙伴们 功能很简单,单点登录,前后端动态权限配 ...

最新文章

  1. 把一个人的特点写具体作文_把一个人的特点写具体500字作文
  2. 简单计算器的设计java_(基于java的简易计算器的设计.doc
  3. jsp当前页的变量值显示到文本框中hint_Word中常用的这9个打印技巧,你不一定全懂,非常实用...
  4. 08 | 替换策略: 缓存满了怎么办?
  5. 链接 动态链接 静态链接
  6. why the SalesOrder header note is read only
  7. linux stm32 ide,一文教你如何在ubuntu上快速搭建STM32 CubeIDE环境(图文超详细+文末有附件)...
  8. 方舟编译器的安装和编译Helloword
  9. eclipse中添加svn插件
  10. pythonopencv算法_OpenCV算法精解 基于Python与C++pdf
  11. B2B网关支付方案介绍
  12. 关于人工智能AI的发展,边缘计算中的AI芯片
  13. 【改变思路】中式英语解决之法
  14. root禁止app后台自启,手机免root自启管理
  15. 用HTML开发Windows桌面应用程序
  16. CloseableHttpClient设置Timeout 设置超时时间
  17. 贴一点代码(用VC实现在WINXP下的宽带拨号)
  18. 网站如何识别网络抓取机器人?
  19. 查看服务器GPU使用情况
  20. 大数据分析案例-基于多元线性回归算法构建广告投放收益模型

热门文章

  1. 不错的linux下通用的java程序启动脚本(转载)
  2. 动态链接库dll,静态链接库lib, 导入库lib 转
  3. 字符设备驱动基本流程
  4. (chap4 IP协议) IP基础知识
  5. (chap6 Http首部) 通用首部字段 Connection
  6. java练气期(2)----java高级(File类与IO流)
  7. [工具]-PGP的使用方法
  8. 仿Mathematica中的函数ProductLog
  9. 利用php打印出九行菱形,PHP新手上路(九)
  10. wxWidgets学习 (2) -- 事件处理