代码拉取完成,页面将自动刷新
基于spring-boot 2.x + quartz 的CRUD任务管理系统,适用于中小项目。
基于spring-boot 1.x + quartz 的CRUD任务管理系统:https://gitee.com/52itstyle/spring-boot-quartz
JDK1.8、Maven、Eclipse
SpringBoot 2.1.6、thymeleaf 3.0.9、quartz 2.3.0、iview、vue、layer、AdminLTE、bootstrap
这里只是针对这两个项目异同做比较,当然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 );
}
}
打开quartz集群配置:
# 打开集群配置
spring.quartz.properties.org.quartz.jobStore.isClustered = true
# 设置集群检查间隔20s
spring.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核心接口有:
作者: 小柒2012
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
代码活跃度
社区活跃度
团队健康
流行趋势
影响力
:与代码提交频次相关
:与项目和用户的issue、pr互动相关
:与团队成员人数和稳定度相关
:与项目近期受关注度相关
:与项目的star、下载量等社交指标相关