springboot2.x开发案例之整合quartz任务管理系统

     2022-03-28     572

关键词:

技术分享图片

基于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

springboot2.x开发案例之前后端分离鉴权

前言阅读本文需要一定的前后端开发基础,前后端分离已成为互联网项目开发的业界标准使用方式,通过Nginx代理+Tomcat的方式有效的进行解耦,并且前后端分离会为以后的大型分布式架构、弹性计算架构、微服务架构、多端化服... 查看详情

springboot2.x实战之定时任务调度

在后端开发中,有些场景是需要使用定时任务的,例如:定时同步一批数据、定时清理一些数据,在SpringBoot中提供了@Scheduled注解就提供了定时调度的功能,对于简单的、单机的调度方案是足够了的。这篇文章准备用实际案例看... 查看详情

springboot2.x实战之定时任务调度

在后端开发中,有些场景是需要使用定时任务的,例如:定时同步一批数据、定时清理一些数据,在SpringBoot中提供了@Scheduled注解就提供了定时调度的功能,对于简单的、单机的调度方案是足够了的。这篇文章准备用实际案例看... 查看详情

springboot2.x最佳实践《一》之springboot2.x初体验

SpringBoot2.X最佳实践前言本系列文章,从零基础接触 SpringBoot2.x新版本,基础入门使用,热部署,到整合各个主流框架Redis4.x,消息队列AciveMQ,RocketMQ等,搜索框架ElasticSearch5.6版本,到web-flux反应式编程,到Actuator监控应用信息... 查看详情

springboot之整合quartz调度框架-基于springboot2.0.2版本

1.项目基础项目是基于SpringBoot2.x版本的  2.添加依赖<!--quartz依赖--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-quartz</artifactId&g 查看详情

springboot之整合quartz调度框架-基于springboot2.0.2版本

1.项目基础项目是基于SpringBoot2.x版本的  2.添加依赖<!--quartz依赖--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-quartz</artifactId&g 查看详情

springboot2.x整合rocketmq4.x

开发生产者代码第一步:创建很普通的SpringBoot项目第二步:加入相关依赖<dependency><groupId>org.apache.rocketmq</groupId><artifactId>rocketmq-client</artifactId><version>4.3.0</version></ 查看详情

springboot2.x微信公众平台开发之接入

声明:本系列纯属自己为了学习而编写,均已测试号为例,如果不正之处,恳请指正,谢谢!接入微信公众平台开发,开发者需要按照如下步骤完成:1、填写服务器配置由于只是接入,只需要一个Controller的方法路径和定义一个tok... 查看详情

springboot2.x:整合mybatis-plus

简介Mybatis-Plus是在Mybatis的基础上,国人开发的一款持久层框架。并且荣获了2018年度开源中国最受欢迎的中国软件TOP5同样以简化开发为宗旨的SpringBoot与Mybatis-Plus放在一起会产生什么样的化学反应呢?下面我们来领略一下两者配... 查看详情

springboot开发案例之整合quartz任务管理系统

...pring-boot+quartz的CRUD动态任务管理系统,适用于中小项目。开发环境JDK1.7、Maven、Eclipse技术栈SpringBoot1.5.2、thymeleaf、quartz2.3.0、iview、vue、layer、AdminLTE、bootstrap启动说明项目使用的数据库为MySql,选择resources/sql中的tables_mysql_innodb.sq... 查看详情

springboot开发案例之整合dubbo分布式服务

前言在SpringBoot很火热的时候,阿里巴巴的分布式框架Dubbo不知是处于什么考虑,在停更N年之后终于进行维护了。在之前的微服务中,使用的是当当维护的版本Dubbox,整合方式也是使用的xml配置方式。改造前之前在SpringBoot中使用D... 查看详情

springboot开发案例之整合dubbo分布式服务

前言在SpringBoot很火热的时候,阿里巴巴的分布式框架Dubbo不知是处于什么考虑,在停更N年之后终于进行维护了。在之前的微服务中,使用的是当当维护的版本Dubbox,整合方式也是使用的xml配置方式。改造前之前在SpringBoot中使用D... 查看详情

springboot开发案例之整合dubbo分布式服务

前言在SpringBoot很火热的时候,阿里巴巴的分布式框架Dubbo不知是处于什么考虑,在停更N年之后终于进行维护了。在之前的微服务中,使用的是当当维护的版本Dubbox,整合方式也是使用的xml配置方式。改造前之前在SpringBoot中使用D... 查看详情

springboot整合thymeleaf-基于springboot2.x版本

1、为啥要用Thymeleaf模板引擎?现在不都前后端分离了么?熊dei们,别着急,我们先来谈谈为啥开始用Thymeleaf模板引擎,先照顾照顾下我们这些可爱的小白童鞋....为啥开始用Thymeleaf模板引擎?jsp她不香嘛?首先前端交给我们的页... 查看详情

springboot2.x版本整合redis集群

参考技术A启动Redis集群搭建方式SpringBoot1.x版本默认使用jedis连接,2.x版本使用lettuce连接ymlyml测试 查看详情

springboot2.x整合redis

#准备工作配置application.ymlspring:thymeleaf:#thymeleafcache:falsedatasource:#datasourcedriver-class-name:com.mysql.cj.jdbc.Driverurl:jdbc:mysql://localhost:3306/mp?useUnicode=true&characterEncoding=utf 查看详情

java微信公众平台开发之素材管理(springboot2.x)

微信素材管理和群发这块文档对Java很不友好。本文只对新增临时素材,新增永久素材做介绍,其余获取、删除、修改自行补充公众号经常有需要用到一些临时性的多媒体素材的场景,例如在使用接口特别是发送消息时,对多媒... 查看详情

网红框架springboot2.x之框架简介及环境搭建

SpringBoot基于Spring框架进行“变态级“封装和扩展,由于上手简单、配置简单、集成简单,使得SpringBoot一跃成为近几年Java开发界的网红,加之众多的开源同僚的鼎力支持,为SpringBoot框架构建起了强大的开发生态圈。SpringBoot1.x已... 查看详情