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
项目截图
版本区别(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
作者: 小柒2012
低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。
持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。
转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。
- 上一篇
使用OpenAPI自动化处理ECS系统事件
什么是系统事件 当您将业务系统部署到阿里云ECS后,阿里云保证ECS计算服务的高可用。在极少情况下,比如探测到ECS实例所在的硬件发生故障,会产生有计划的维护事件并通知您。 深入了解系统事件,请参考: 实例系统事件 让运维更高效:关于ECS系统事件 监控和应对系统事件的方式 为了业务的平稳运行,您需要监控ECS系统事件并及时合理地应对系统事件。 从控制台处理ECS主动运维事件请参考 ECS主动运维事件--让你HOLD住全场 相对于收到通知后登陆ECS控制台人工处理系统事件,通过程序自动化监控和处理系统事件,能够提高您的运维效率,消除遗漏或出错的可能性,让您的运维人员不用再为半夜的故障通知而烦恼。如果您保有较多的ECS实例,自动化程序的优点将会更加突出。 ECS为您提供了两个OpenAPI来监控实例的健康状态和系统事件。 1. DescribeInst
- 下一篇
设计模式快速学习(二)抽象工厂模式
抽象工厂模式(Abstract Factory Pattern)是围绕一个超级工厂创建其他工厂。该超级工厂又称为其他工厂的工厂。这种类型的设计模式属于创建型模式,它提供了一种创建对象的最佳方式。 直接上demo.先代码,后介绍。 如果在之前你没有看过工厂模式,请坐下面的时光机传送,不光是思想基础,主要是演变的过程要知道。设计模式快速学习(一)工厂模式 1. 编写接口Shape Shape.java public interface Shape { void draw(); } 2. 编写接口Shape的实现类Rectangle Rectangle.java /** * Created by Fant.J. */ public class Rectangle implements Shape { @Override public void describe() { System.out.println("我是个长方形"); } } 3. 编写接口Shape的实现类Circle Circle .java /** * Created by Fant.J. */ public class Ci...
相关文章
文章评论
共有0条评论来说两句吧...
文章二维码
点击排行
推荐阅读
最新文章
- CentOS关闭SELinux安全模块
- SpringBoot2编写第一个Controller,响应你的http请求并返回结果
- Mario游戏-低调大师作品
- CentOS6,CentOS7官方镜像安装Oracle11G
- SpringBoot2配置默认Tomcat设置,开启更多高级功能
- Windows10,CentOS7,CentOS8安装Nodejs环境
- Docker安装Oracle12C,快速搭建Oracle学习环境
- Windows10,CentOS7,CentOS8安装MongoDB4.0.16
- CentOS8编译安装MySQL8.0.19
- MySQL8.0.19开启GTID主从同步CentOS8