Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
sts网站
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liyang
sts网站
Commits
d0f7a317
Commit
d0f7a317
authored
Feb 22, 2022
by
RuoYi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
定时任务默认保存到内存中执行
parent
aa9ed2e8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
57 deletions
+57
-57
ScheduleConfig.java
...src/main/java/com/ruoyi/quartz/config/ScheduleConfig.java
+57
-57
No files found.
ruoyi-quartz/src/main/java/com/ruoyi/quartz/config/ScheduleConfig.java
View file @
d0f7a317
package
com
.
ruoyi
.
quartz
.
config
;
//
package com.ruoyi.quartz.config;
//
import
org.springframework.context.annotation.Bean
;
//
import org.springframework.context.annotation.Bean;
import
org.springframework.context.annotation.Configuration
;
//
import org.springframework.context.annotation.Configuration;
import
org.springframework.scheduling.quartz.SchedulerFactoryBean
;
//
import org.springframework.scheduling.quartz.SchedulerFactoryBean;
import
javax.sql.DataSource
;
//
import javax.sql.DataSource;
import
java.util.Properties
;
//
import java.util.Properties;
//
/**
/
//
**
* 定时任务配置(单机部署建议删除此类和qrtz数据库表,默认走内存会最高效)
//
* 定时任务配置(单机部署建议删除此类和qrtz数据库表,默认走内存会最高效)
*
//
*
* @author ruoyi
//
* @author ruoyi
*/
//
*/
@Configuration
//
@Configuration
public
class
ScheduleConfig
//
public class ScheduleConfig
{
//
{
@Bean
//
@Bean
public
SchedulerFactoryBean
schedulerFactoryBean
(
DataSource
dataSource
)
//
public SchedulerFactoryBean schedulerFactoryBean(DataSource dataSource)
{
//
{
SchedulerFactoryBean
factory
=
new
SchedulerFactoryBean
();
//
SchedulerFactoryBean factory = new SchedulerFactoryBean();
factory
.
setDataSource
(
dataSource
);
//
factory.setDataSource(dataSource);
//
// quartz参数
//
// quartz参数
Properties
prop
=
new
Properties
();
//
Properties prop = new Properties();
prop
.
put
(
"org.quartz.scheduler.instanceName"
,
"RuoyiScheduler"
);
//
prop.put("org.quartz.scheduler.instanceName", "RuoyiScheduler");
prop
.
put
(
"org.quartz.scheduler.instanceId"
,
"AUTO"
);
//
prop.put("org.quartz.scheduler.instanceId", "AUTO");
// 线程池配置
//
// 线程池配置
prop
.
put
(
"org.quartz.threadPool.class"
,
"org.quartz.simpl.SimpleThreadPool"
);
//
prop.put("org.quartz.threadPool.class", "org.quartz.simpl.SimpleThreadPool");
prop
.
put
(
"org.quartz.threadPool.threadCount"
,
"20"
);
//
prop.put("org.quartz.threadPool.threadCount", "20");
prop
.
put
(
"org.quartz.threadPool.threadPriority"
,
"5"
);
//
prop.put("org.quartz.threadPool.threadPriority", "5");
// JobStore配置
//
// JobStore配置
prop
.
put
(
"org.quartz.jobStore.class"
,
"org.springframework.scheduling.quartz.LocalDataSourceJobStore"
);
//
prop.put("org.quartz.jobStore.class", "org.springframework.scheduling.quartz.LocalDataSourceJobStore");
// 集群配置
//
// 集群配置
prop
.
put
(
"org.quartz.jobStore.isClustered"
,
"true"
);
//
prop.put("org.quartz.jobStore.isClustered", "true");
prop
.
put
(
"org.quartz.jobStore.clusterCheckinInterval"
,
"15000"
);
//
prop.put("org.quartz.jobStore.clusterCheckinInterval", "15000");
prop
.
put
(
"org.quartz.jobStore.maxMisfiresToHandleAtATime"
,
"1"
);
//
prop.put("org.quartz.jobStore.maxMisfiresToHandleAtATime", "1");
prop
.
put
(
"org.quartz.jobStore.txIsolationLevelSerializable"
,
"true"
);
//
prop.put("org.quartz.jobStore.txIsolationLevelSerializable", "true");
//
// sqlserver 启用
//
// sqlserver 启用
// prop.put("org.quartz.jobStore.selectWithLockSQL", "SELECT * FROM {0}LOCKS UPDLOCK WHERE LOCK_NAME = ?");
//
// prop.put("org.quartz.jobStore.selectWithLockSQL", "SELECT * FROM {0}LOCKS UPDLOCK WHERE LOCK_NAME = ?");
prop
.
put
(
"org.quartz.jobStore.misfireThreshold"
,
"12000"
);
//
prop.put("org.quartz.jobStore.misfireThreshold", "12000");
prop
.
put
(
"org.quartz.jobStore.tablePrefix"
,
"QRTZ_"
);
//
prop.put("org.quartz.jobStore.tablePrefix", "QRTZ_");
factory
.
setQuartzProperties
(
prop
);
//
factory.setQuartzProperties(prop);
//
factory
.
setSchedulerName
(
"RuoyiScheduler"
);
//
factory.setSchedulerName("RuoyiScheduler");
// 延时启动
//
// 延时启动
factory
.
setStartupDelay
(
1
);
//
factory.setStartupDelay(1);
factory
.
setApplicationContextSchedulerContextKey
(
"applicationContextKey"
);
//
factory.setApplicationContextSchedulerContextKey("applicationContextKey");
// 可选,QuartzScheduler
//
// 可选,QuartzScheduler
// 启动时更新己存在的Job,这样就不用每次修改targetObject后删除qrtz_job_details表对应记录了
//
// 启动时更新己存在的Job,这样就不用每次修改targetObject后删除qrtz_job_details表对应记录了
factory
.
setOverwriteExistingJobs
(
true
);
//
factory.setOverwriteExistingJobs(true);
// 设置自动启动,默认为true
//
// 设置自动启动,默认为true
factory
.
setAutoStartup
(
true
);
//
factory.setAutoStartup(true);
//
return
factory
;
//
return factory;
}
//
}
}
//
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment