前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >SpringBoot2.x开发案例之整合Quartz任务管理系统

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

作者头像
小柒2012
发布2019-12-09 16:31:58
7500
发布2019-12-09 16:31:58
举报
文章被收录于专栏:IT笔记IT笔记

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

项目截图

1.png
1.png
2.png
2.png
3.png
3.png
4.png
4.png
5.png
5.png
6.png
6.png

项目源码: https://gitee.com/52itstyle/spring-boot-task

版本区别(spring-boot 1.x and 2.x)

这里只是针对这两个项目异同做比较,当然spring-boot 2.x版本升级还有不少需要注意的地方。

项目名称配置:

代码语言:javascript
复制
# spring boot 1.x
server.context-path=/quartz
# spring boot 2.x
server.servlet.context-path=/quartz

thymeleaf配置:

代码语言:javascript
复制
#spring boot 1.x
spring.thymeleaf.mode=LEGACYHTML5
#spring boot 2.x
spring.thymeleaf.mode=HTML

Hibernate配置:

代码语言:javascript
复制
# 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配置:

代码语言:javascript
复制
# 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

默认首页配置:

代码语言:javascript
复制
/**
 * 配置首页 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 );
    } 
}
代码语言:javascript
复制
/**
 * 配置首页(在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 );
    } 
}

待解决问题:

代码语言:javascript
复制
/**
     * 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

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2018-04-11,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 开发环境
  • 技术栈
  • 启动说明
  • 项目截图
  • 版本区别(spring-boot 1.x and 2.x)
相关产品与服务
数据库
云数据库为企业提供了完善的关系型数据库、非关系型数据库、分析型数据库和数据库生态工具。您可以通过产品选择和组合搭建,轻松实现高可靠、高可用性、高性能等数据库需求。云数据库服务也可大幅减少您的运维工作量,更专注于业务发展,让企业一站式享受数据上云及分布式架构的技术红利!
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档