概述

  项目需要定时器的调度管理,原来使用Spring Boot自带的定时器,但是不能后台动态的操作暂停、启动以及新增任务等操作,维护起来相对麻烦;最近研究了Quartz的框架,觉得还算不错,整理了一下代码,整合到现有系统里面,整体效果如下图所示,记录操作流程如下文。

数据库

  将Quartz依赖的数据库脚本提交现有项目数据库,脚本如下:

DROP TABLE IF EXISTS QRTZ_FIRED_TRIGGERS;
DROP TABLE IF EXISTS QRTZ_PAUSED_TRIGGER_GRPS;
DROP TABLE IF EXISTS QRTZ_SCHEDULER_STATE;
DROP TABLE IF EXISTS QRTZ_LOCKS;
DROP TABLE IF EXISTS QRTZ_SIMPLE_TRIGGERS;
DROP TABLE IF EXISTS QRTZ_SIMPROP_TRIGGERS;
DROP TABLE IF EXISTS QRTZ_CRON_TRIGGERS;
DROP TABLE IF EXISTS QRTZ_BLOB_TRIGGERS;
DROP TABLE IF EXISTS QRTZ_TRIGGERS;
DROP TABLE IF EXISTS QRTZ_JOB_DETAILS;
DROP TABLE IF EXISTS QRTZ_CALENDARS; CREATE TABLE QRTZ_JOB_DETAILS
(
SCHED_NAME VARCHAR() NOT NULL,
JOB_NAME VARCHAR() NOT NULL,
JOB_GROUP VARCHAR() NOT NULL,
DESCRIPTION VARCHAR() NULL,
JOB_CLASS_NAME VARCHAR() NOT NULL,
IS_DURABLE VARCHAR() NOT NULL,
IS_NONCONCURRENT VARCHAR() NOT NULL,
IS_UPDATE_DATA VARCHAR() NOT NULL,
REQUESTS_RECOVERY VARCHAR() NOT NULL,
JOB_DATA BLOB NULL,
PRIMARY KEY (SCHED_NAME,JOB_NAME,JOB_GROUP)
); CREATE TABLE QRTZ_TRIGGERS
(
SCHED_NAME VARCHAR() NOT NULL,
TRIGGER_NAME VARCHAR() NOT NULL,
TRIGGER_GROUP VARCHAR() NOT NULL,
JOB_NAME VARCHAR() NOT NULL,
JOB_GROUP VARCHAR() NOT NULL,
DESCRIPTION VARCHAR() NULL,
NEXT_FIRE_TIME BIGINT() NULL,
PREV_FIRE_TIME BIGINT() NULL,
PRIORITY INTEGER NULL,
TRIGGER_STATE VARCHAR() NOT NULL,
TRIGGER_TYPE VARCHAR() NOT NULL,
START_TIME BIGINT() NOT NULL,
END_TIME BIGINT() NULL,
CALENDAR_NAME VARCHAR() NULL,
MISFIRE_INSTR SMALLINT() NULL,
JOB_DATA BLOB NULL,
PRIMARY KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP),
FOREIGN KEY (SCHED_NAME,JOB_NAME,JOB_GROUP)
REFERENCES QRTZ_JOB_DETAILS(SCHED_NAME,JOB_NAME,JOB_GROUP)
); CREATE TABLE QRTZ_SIMPLE_TRIGGERS
(
SCHED_NAME VARCHAR() NOT NULL,
TRIGGER_NAME VARCHAR() NOT NULL,
TRIGGER_GROUP VARCHAR() NOT NULL,
REPEAT_COUNT BIGINT() NOT NULL,
REPEAT_INTERVAL BIGINT() NOT NULL,
TIMES_TRIGGERED BIGINT() NOT NULL,
PRIMARY KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP),
FOREIGN KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)
REFERENCES QRTZ_TRIGGERS(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)
); CREATE TABLE QRTZ_CRON_TRIGGERS
(
SCHED_NAME VARCHAR() NOT NULL,
TRIGGER_NAME VARCHAR() NOT NULL,
TRIGGER_GROUP VARCHAR() NOT NULL,
CRON_EXPRESSION VARCHAR() NOT NULL,
TIME_ZONE_ID VARCHAR(),
PRIMARY KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP),
FOREIGN KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)
REFERENCES QRTZ_TRIGGERS(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)
); CREATE TABLE QRTZ_SIMPROP_TRIGGERS
(
SCHED_NAME VARCHAR() NOT NULL,
TRIGGER_NAME VARCHAR() NOT NULL,
TRIGGER_GROUP VARCHAR() NOT NULL,
STR_PROP_1 VARCHAR() NULL,
STR_PROP_2 VARCHAR() NULL,
STR_PROP_3 VARCHAR() NULL,
INT_PROP_1 INT NULL,
INT_PROP_2 INT NULL,
LONG_PROP_1 BIGINT NULL,
LONG_PROP_2 BIGINT NULL,
DEC_PROP_1 NUMERIC(,) NULL,
DEC_PROP_2 NUMERIC(,) NULL,
BOOL_PROP_1 VARCHAR() NULL,
BOOL_PROP_2 VARCHAR() NULL,
PRIMARY KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP),
FOREIGN KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)
REFERENCES QRTZ_TRIGGERS(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)
); CREATE TABLE QRTZ_BLOB_TRIGGERS
(
SCHED_NAME VARCHAR() NOT NULL,
TRIGGER_NAME VARCHAR() NOT NULL,
TRIGGER_GROUP VARCHAR() NOT NULL,
BLOB_DATA BLOB NULL,
PRIMARY KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP),
FOREIGN KEY (SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)
REFERENCES QRTZ_TRIGGERS(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP)
); CREATE TABLE QRTZ_CALENDARS
(
SCHED_NAME VARCHAR() NOT NULL,
CALENDAR_NAME VARCHAR() NOT NULL,
CALENDAR BLOB NOT NULL,
PRIMARY KEY (SCHED_NAME,CALENDAR_NAME)
); CREATE TABLE QRTZ_PAUSED_TRIGGER_GRPS
(
SCHED_NAME VARCHAR() NOT NULL,
TRIGGER_GROUP VARCHAR() NOT NULL,
PRIMARY KEY (SCHED_NAME,TRIGGER_GROUP)
); CREATE TABLE QRTZ_FIRED_TRIGGERS
(
SCHED_NAME VARCHAR() NOT NULL,
ENTRY_ID VARCHAR() NOT NULL,
TRIGGER_NAME VARCHAR() NOT NULL,
TRIGGER_GROUP VARCHAR() NOT NULL,
INSTANCE_NAME VARCHAR() NOT NULL,
FIRED_TIME BIGINT() NOT NULL,
SCHED_TIME BIGINT() NOT NULL,
PRIORITY INTEGER NOT NULL,
STATE VARCHAR() NOT NULL,
JOB_NAME VARCHAR() NULL,
JOB_GROUP VARCHAR() NULL,
IS_NONCONCURRENT VARCHAR() NULL,
REQUESTS_RECOVERY VARCHAR() NULL,
PRIMARY KEY (SCHED_NAME,ENTRY_ID)
); CREATE TABLE QRTZ_SCHEDULER_STATE
(
SCHED_NAME VARCHAR() NOT NULL,
INSTANCE_NAME VARCHAR() NOT NULL,
LAST_CHECKIN_TIME BIGINT() NOT NULL,
CHECKIN_INTERVAL BIGINT() NOT NULL,
PRIMARY KEY (SCHED_NAME,INSTANCE_NAME)
); CREATE TABLE QRTZ_LOCKS
(
SCHED_NAME VARCHAR() NOT NULL,
LOCK_NAME VARCHAR() NOT NULL,
PRIMARY KEY (SCHED_NAME,LOCK_NAME)
); commit;

代码编写

添加Maven依赖包

        <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-quartz</artifactId>
<version>RELEASE</version>
</dependency>

添加Quartz配置类

1>、QuartzJobFactory.JAVA(注册JOB工厂类,主要是为了集成Sping Boot的注解管理类使用)

package com.dbgo.quartzdemo.config;

import org.quartz.spi.TriggerFiredBundle;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.scheduling.quartz.AdaptableJobFactory;
import org.springframework.stereotype.Component; @Component
public class QuartzJobFactory extends AdaptableJobFactory { /**
* AutowireCapableBeanFactory接口是BeanFactory的子类
* 可以连接和填充那些生命周期不被Spring管理的已存在的bean实例
* 具体请参考:http://blog.csdn.net/iycynna_123/article/details/52993542
*/
@Autowired
private AutowireCapableBeanFactory capableBeanFactory; /**
* 创建Job实例
*
* @param bundle
* @return
* @throws Exception
*/
@Override
protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception {
// 实例化对象
Object jobInstance = super.createJobInstance(bundle);
// 进行注入(Spring管理该Bean)
capableBeanFactory.autowireBean(jobInstance);
//返回对象
return jobInstance;
}
}

2>、SchedulerConfig.JAVA(注册调度框架的实例,配置依赖的JobFactory和属性)

package com.dbgo.quartzdemo.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.PropertiesFactoryBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import org.springframework.scheduling.quartz.SchedulerFactoryBean; import java.io.IOException;
import java.util.Properties; @Configuration
public class SchedulerConfig { @Autowired
private QuartzJobFactory quartzJobFactory; @Bean(name = "quartzScheduler")
public SchedulerFactoryBean schedulerFactoryBean() throws IOException {
SchedulerFactoryBean factory = new SchedulerFactoryBean();
//用于quartz集群,QuartzScheduler 启动时更新己存在的Job,这样就不用每次修改targetObject后删除qrtz_job_details表对应记录了
//factory.setOverwriteExistingJobs(true);
//QuartzScheduler 延时启动,应用启动完10秒后 QuartzScheduler 再启动
factory.setStartupDelay();
factory.setAutoStartup(true);
factory.setOverwriteExistingJobs(true);
factory.setQuartzProperties(quartzProperties()); //作业及数据源配置信息
// 自定义Job Factory,用于Spring注入 service,bin等 factory.setJobFactory(quartzJobFactory); return factory;
} @Bean
public Properties quartzProperties() throws IOException {
PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean();
propertiesFactoryBean.setLocation(new ClassPathResource("/quartz.properties"));
//在quartz.properties中的属性被读取并注入后再初始化对象
propertiesFactoryBean.afterPropertiesSet();
return propertiesFactoryBean.getObject();
}
}

3>、DruidConnectionProvider.JAVA(配置Quartz的数据库连接,读取项目下的quartz.properties文件属性)

package com.dbgo.quartzdemo.config;

import java.sql.Connection;
import java.sql.SQLException;
import org.quartz.SchedulerException;
import org.quartz.utils.ConnectionProvider; import com.alibaba.druid.pool.DruidDataSource; public class DruidConnectionProvider implements ConnectionProvider { //JDBC驱动
public String driver;
//JDBC连接串
public String URL;
//数据库用户名
public String user;
//数据库用户密码
public String password;
//数据库最大连接数
public int maxConnection;
//数据库SQL查询每次连接返回执行到连接池,以确保它仍然是有效的。
public String validationQuery;
private boolean validateOnCheckout;
private int idleConnectionValidationSeconds;
public String maxCachedStatementsPerConnection;
private String discardIdleConnectionsSeconds;
public static final int DEFAULT_DB_MAX_CONNECTIONS = ;
public static final int DEFAULT_DB_MAX_CACHED_STATEMENTS_PER_CONNECTION = ;
//Druid连接池
private DruidDataSource datasource;
/*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
* 接口实现
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
public Connection getConnection() throws SQLException {
return datasource.getConnection();
}
public void shutdown() throws SQLException {
datasource.close();
}
public void initialize() throws SQLException{
if (this.URL == null) {
throw new SQLException("DBPool could not be created: DB URL cannot be null");
}
if (this.driver == null) {
throw new SQLException("DBPool driver could not be created: DB driver class name cannot be null!");
}
if (this.maxConnection < ) {
throw new SQLException("DBPool maxConnectins could not be created: Max connections must be greater than zero!");
}
datasource = new DruidDataSource();
try{
datasource.setDriverClassName(this.driver);
} catch (Exception e) {
try {
throw new SchedulerException("Problem setting driver class name on datasource: " + e.getMessage(), e);
} catch (SchedulerException e1) {
}
}
datasource.setUrl(this.URL);
datasource.setUsername(this.user);
datasource.setPassword(this.password);
datasource.setMaxActive(this.maxConnection);
datasource.setMinIdle();
datasource.setMaxWait();
datasource.setMaxPoolPreparedStatementPerConnectionSize(DEFAULT_DB_MAX_CONNECTIONS);
if (this.validationQuery != null) {
datasource.setValidationQuery(this.validationQuery);
if(!this.validateOnCheckout)
datasource.setTestOnReturn(true);
else
datasource.setTestOnBorrow(true);
datasource.setValidationQueryTimeout(this.idleConnectionValidationSeconds);
}
}
/*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
* 提供get set方法
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
public String getDriver() {
return driver;
}
public void setDriver(String driver) {
this.driver = driver;
}
public String getURL() {
return URL;
}
public void setURL(String URL) {
this.URL = URL;
}
public String getUser() {
return user;
}
public void setUser(String user) {
this.user = user;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public int getMaxConnection() {
return maxConnection;
}
public void setMaxConnection(int maxConnection) {
this.maxConnection = maxConnection;
}
public String getValidationQuery() {
return validationQuery;
}
public void setValidationQuery(String validationQuery) {
this.validationQuery = validationQuery;
}
public boolean isValidateOnCheckout() {
return validateOnCheckout;
}
public void setValidateOnCheckout(boolean validateOnCheckout) {
this.validateOnCheckout = validateOnCheckout;
}
public int getIdleConnectionValidationSeconds() {
return idleConnectionValidationSeconds;
}
public void setIdleConnectionValidationSeconds(int idleConnectionValidationSeconds) {
this.idleConnectionValidationSeconds = idleConnectionValidationSeconds;
}
public DruidDataSource getDatasource() {
return datasource;
}
public void setDatasource(DruidDataSource datasource) {
this.datasource = datasource;
}
public String getDiscardIdleConnectionsSeconds() {
return discardIdleConnectionsSeconds;
}
public void setDiscardIdleConnectionsSeconds(String discardIdleConnectionsSeconds) {
this.discardIdleConnectionsSeconds = discardIdleConnectionsSeconds;
} }

4>、添加定时任务DEMO(这个Demo仅仅模拟正常业务工作的Job,项目写Job的时候可以参考)

package com.dbgo.quartzdemo.job;

import java.util.Date;

import org.apache.jasper.tagplugins.jstl.core.Catch;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.stereotype.Component; @Component
//@DisallowConcurrentExecution //保证上一次任务执行完毕再执行下一任务
public class HelloWorldJob implements Job{ /**
* "0/10 * * * * ?
*/
@Override
public void execute(JobExecutionContext arg0) throws JobExecutionException {
try { System.out.println("----START---hello world---" + new Date());
Thread.sleep(*);
System.out.println("----END---hello world---" + new Date());
} catch (Exception ex) {
} } }

添加Quartz服务类

1>、QuartzService.java的接口

package com.dbgo.quartzdemo.domain.api;

public interface QuartzService {

    /**
* addJob(方法描述:添加一个定时任务) <br />
* (方法适用条件描述: – 可选)
*
* @param jobName
* 作业名称
* @param jobGroupName
* 作业组名称
* @param triggerName
* 触发器名称
* @param triggerGroupName
* 触发器组名称
* @param cls
* 定时任务的class
* @param cron
* 时间表达式 void
* @exception
* @since 1.0.0
*/
public void addJob(String jobName, String jobGroupName, String triggerName, String triggerGroupName, Class cls, String cron); /**
*
* @param oldjobName 原job name
* @param oldjobGroup 原job group
* @param oldtriggerName 原 trigger name
* @param oldtriggerGroup 原 trigger group
* @param jobName
* @param jobGroup
* @param triggerName
* @param triggerGroup
* @param cron
*/
public boolean modifyJobTime(String oldjobName, String oldjobGroup, String oldtriggerName, String oldtriggerGroup, String jobName, String jobGroup, String triggerName, String triggerGroup, String cron); /**
* 修改触发器调度时间
* @param triggerName 触发器名称
* @param triggerGroupName 触发器组名称
* @param cron cron表达式
*/
public void modifyJobTime(String triggerName,
String triggerGroupName, String cron); /**
* 暂停指定的任务
* @param jobName 任务名称
* @param jobGroupName 任务组名称
* @return
*/
public void pauseJob(String jobName, String jobGroupName); /**
* 恢复指定的任务
* @param jobName 任务名称
* @param jobGroupName 任务组名称
* @return
*/
public void resumeJob(String jobName, String jobGroupName); /**
* 删除指定组任务
* @param jobName 作业名称
* @param jobGroupName 作业组名称
* @param triggerName 触发器名称
* @param triggerGroupName 触发器组名称
*/
public void removeJob(String jobName, String jobGroupName,
String triggerName, String triggerGroupName); /**
* 开始所有定时任务。启动调度器
*/
public void startSchedule(); /**
* 关闭调度器
*/
public void shutdownSchedule();
}

2>、QuartzServiceImpl.java的接口实现类

package com.dbgo.quartzdemo.domain.server;

import com.dbgo.quartzdemo.domain.api.QuartzService;
import org.quartz.CronScheduleBuilder;
import org.quartz.CronTrigger;
import org.quartz.JobBuilder;
import org.quartz.JobDetail;
import org.quartz.JobKey;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.TriggerBuilder;
import org.quartz.TriggerKey;
import org.quartz.impl.StdSchedulerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; @Service("quartzService")
public class QuartzServiceImpl implements QuartzService { @Autowired
private Scheduler quartzScheduler; @Override
public void addJob(String jobName, String jobGroupName, String triggerName,
String triggerGroupName, Class cls, String cron) {
try {
// 获取调度器
Scheduler sched = quartzScheduler;
// 创建一项作业
JobDetail job = JobBuilder.newJob(cls)
.withIdentity(jobName, jobGroupName).build();
// 创建一个触发器
CronTrigger trigger = TriggerBuilder.newTrigger()
.withIdentity(triggerName, triggerGroupName)
.withSchedule(CronScheduleBuilder.cronSchedule(cron))
.build(); // 告诉调度器使用该触发器来安排作业
sched.scheduleJob(job, trigger);
// 启动
if (!sched.isShutdown()) {
sched.start();
}
} catch (Exception e) {
throw new RuntimeException(e);
}
} /**
* 修改定时器任务信息
*/
@Override
public boolean modifyJobTime(String oldjobName, String oldjobGroup, String oldtriggerName, String oldtriggerGroup, String jobName, String jobGroup,
String triggerName, String triggerGroup, String cron) {
try {
Scheduler sched = quartzScheduler;
CronTrigger trigger = (CronTrigger) sched.getTrigger(TriggerKey
.triggerKey(oldtriggerName, oldtriggerGroup));
if (trigger == null) {
return false;
} JobKey jobKey = JobKey.jobKey(oldjobName, oldjobGroup);
TriggerKey triggerKey = TriggerKey.triggerKey(oldtriggerName,
oldtriggerGroup); JobDetail job = sched.getJobDetail(jobKey);
Class jobClass = job.getJobClass();
// 停止触发器
sched.pauseTrigger(triggerKey);
// 移除触发器
sched.unscheduleJob(triggerKey);
// 删除任务
sched.deleteJob(jobKey); addJob(jobName, jobGroup, triggerName, triggerGroup, jobClass,
cron); return true;
} catch (Exception e) {
throw new RuntimeException(e);
} } @Override
public void modifyJobTime(String triggerName, String triggerGroupName,
String time) {
try {
Scheduler sched = quartzScheduler;
CronTrigger trigger = (CronTrigger) sched.getTrigger(TriggerKey
.triggerKey(triggerName, triggerGroupName));
if (trigger == null) {
return;
}
String oldTime = trigger.getCronExpression();
if (!oldTime.equalsIgnoreCase(time)) {
CronTrigger ct = (CronTrigger) trigger;
// 修改时间
ct.getTriggerBuilder()
.withSchedule(CronScheduleBuilder.cronSchedule(time))
.build();
// 重启触发器
sched.resumeTrigger(TriggerKey.triggerKey(triggerName,
triggerGroupName));
}
} catch (Exception e) {
throw new RuntimeException(e);
}
} @Override
public void removeJob(String jobName, String jobGroupName,
String triggerName, String triggerGroupName) {
try {
Scheduler sched = quartzScheduler;
// 停止触发器
sched.pauseTrigger(TriggerKey.triggerKey(triggerName,
triggerGroupName));
// 移除触发器
sched.unscheduleJob(TriggerKey.triggerKey(triggerName,
triggerGroupName));
// 删除任务
sched.deleteJob(JobKey.jobKey(jobName, jobGroupName));
} catch (Exception e) {
throw new RuntimeException(e);
}
} @Override
public void startSchedule() {
try {
Scheduler sched = quartzScheduler;
sched.start();
} catch (Exception e) {
throw new RuntimeException(e);
}
} @Override
public void shutdownSchedule() {
try {
Scheduler sched = quartzScheduler;
if (!sched.isShutdown()) {
sched.shutdown();
}
} catch (Exception e) {
throw new RuntimeException(e);
}
} @Override
public void pauseJob(String jobName, String jobGroupName) {
try {
quartzScheduler.pauseJob( JobKey.jobKey(jobName, jobGroupName));
} catch (SchedulerException e) {
e.printStackTrace();
} } @Override
public void resumeJob(String jobName, String jobGroupName) {
try {
quartzScheduler.resumeJob(JobKey.jobKey(jobName, jobGroupName));
} catch (SchedulerException e) {
e.printStackTrace();
}
} }

添加QuartzController以及WEB就在此忽略了,附件部分是项目的代码,仅供参考和学习;

完整代码下载

Spring Boot 整合Quartz定时器的更多相关文章

  1. spring boot 整合quartz ,job不能注入的问题

    在使用spring boot 整合quartz的时候,新建定时任务类,实现job接口,在使用@AutoWire或者@Resource时,运行时出现nullpointException的问题.显然是相关 ...

  2. spring boot整合quartz实现多个定时任务

        版权声明:本文为博主原创文章,转载请注明出处. https://blog.csdn.net/liuchuanhong1/article/details/78543574 最近收到了很多封邮件, ...

  3. spring boot 整合 quartz 集群环境 实现 动态定时任务配置【原】

    最近做了一个spring boot 整合 quartz  实现 动态定时任务配置,在集群环境下运行的 任务.能够对定时任务,动态的进行增删改查,界面效果图如下: 1. 在项目中引入jar 2. 将需要 ...

  4. Spring Boot整合Quartz实现定时任务表配置

    最近有个小项目要做,spring mvc下的task设置一直不太灵活,因此在Spring Boot上想做到灵活的管理定时任务.需求就是,当项目启动的时候,如果有定时任务则加载进来,生成schedule ...

  5. spring boot整合quartz定时任务案例

    1.运行环境 开发工具:intellij idea JDK版本:1.8 项目管理工具:Maven 4.0.0 2.GITHUB地址 https://github.com/nbfujx/springBo ...

  6. 【Spring Boot学习之六】Spring Boot整合定时任务&异步调用

    环境 eclipse 4.7 jdk 1.8 Spring Boot 1.5.2一.定时任务1.启动类添加注解@EnableScheduling 用于开启定时任务 package com.wjy; i ...

  7. Spring Boot 整合 Elasticsearch,实现 function score query 权重分查询

    摘要: 原创出处 www.bysocket.com 「泥瓦匠BYSocket 」欢迎转载,保留摘要,谢谢! 『 预见未来最好的方式就是亲手创造未来 – <史蒂夫·乔布斯传> 』 运行环境: ...

  8. spring boot整合jsp的那些坑(spring boot 学习笔记之三)

    Spring Boot 整合 Jsp 步骤: 1.新建一个spring boot项目 2.修改pom文件 <dependency>            <groupId>or ...

  9. spring boot 系列之四:spring boot 整合JPA

    上一篇我们讲了spring boot 整合JdbcTemplate来进行数据的持久化, 这篇我们来说下怎么通过spring boot 整合JPA来实现数据的持久化. 一.代码实现 修改pom,引入依赖 ...

随机推荐

  1. msyql存储数据时字段被截断

    关于mysql中字段类型为text文本存储json格式数据,字段被截断的问题 背景: 字段类型 MEDIUMTEXT 确定存储内容5548个字符,换算为字节不超过16M 数据库内已经存在更长内容的存储 ...

  2. echarts 折线拐点收藏

    拐点的样式有:

  3. JavaScript传递参数方法

    1.SetTimer传递参数 setTimeout(function (obj) { obj.myScroll = new IScroll('#wrapper', { click: true }); ...

  4. PMP知识点(五)——资源管理表示方法

    资源矩阵 最常用的为RACI责任矩阵 如下: 资源数据表: 即时间和资源类型的交叉表,是资源直方图的拓展: 资源甘特图: 一种是以任务为索引 一级目录为任务,二级目录为资源,横坐标为时间进度 一种是以 ...

  5. Axis2 WebService客户端Axis2调用

    第一RPC方式,不生成客户端代码 第二,document方式,不生成客户端代码 第三,用wsdl2java工具,生成客户端方式调用 package samples.quickstart.client; ...

  6. #2 numpy pandas初步学习记录

    对numpy中的array进行了了解,array方法的取值arr_2d[0:2, 0:2] pandas 1,read_CSV方法 2,head方法 3,loc方法,取值前开后开, 4,replace ...

  7. spring kafka生产、消费消息

    参考网址: https://blog.csdn.net/lansetiankong12/article/details/54946641 1.新建Maven项目-KafkaMaven ->点击n ...

  8. Python中所有的关键字

    在python中若想查询python中有哪些关键字可以先导入keyword模块 import keyword #导入关键字模块print(keyword.kwlist) #查询所有关键字 查询结果: ...

  9. java 中final关键字

    1.final变量,一旦该变量被设定,就不可以再改变该变量的值. final关键字定义的变量必须声明时赋值.一旦一个对象引用被修饰为final后,它只能恒定指向一个对象,一个既是static和fina ...

  10. 更改checkbox的默认样式

    最近做一个vue项目要用到checkbox要修改默认样式,选中是纯白色,不选择只有白色边框,起初以为很容易,没想到还折腾了一翻,记录一下. 几经折腾,理清input 和label的关系 最终改进版本, ...