Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Eladmin
Commits
08f6c582
You need to sign in or sign up before continuing.
Commit
08f6c582
authored
Nov 16, 2021
by
Zheng Jie
Browse files
close
https://github.com/elunez/eladmin/issues/692
parent
7167f292
Changes
2
Hide whitespace changes
Inline
Side-by-side
eladmin-system/src/main/java/me/zhengjie/modules/quartz/config/QuartzConfig.java
View file @
08f6c582
...
...
@@ -15,13 +15,10 @@
*/
package
me.zhengjie.modules.quartz.config
;
import
org.quartz.Scheduler
;
import
org.quartz.spi.TriggerFiredBundle
;
import
org.springframework.beans.factory.config.AutowireCapableBeanFactory
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.scheduling.quartz.AdaptableJobFactory
;
import
org.springframework.scheduling.quartz.SchedulerFactoryBean
;
import
org.springframework.stereotype.Component
;
/**
...
...
@@ -46,27 +43,10 @@ public class QuartzConfig {
@Override
protected
Object
createJobInstance
(
TriggerFiredBundle
bundle
)
throws
Exception
{
//调用父类的方法
//调用父类的方法,把Job注入到spring中
Object
jobInstance
=
super
.
createJobInstance
(
bundle
);
capableBeanFactory
.
autowireBean
(
jobInstance
);
return
jobInstance
;
}
}
/**
* 注入scheduler到spring
* @param quartzJobFactory /
* @return Scheduler
* @throws Exception /
*/
@Bean
(
name
=
"scheduler"
)
public
Scheduler
scheduler
(
QuartzJobFactory
quartzJobFactory
)
throws
Exception
{
SchedulerFactoryBean
factoryBean
=
new
SchedulerFactoryBean
();
factoryBean
.
setJobFactory
(
quartzJobFactory
);
factoryBean
.
afterPropertiesSet
();
Scheduler
scheduler
=
factoryBean
.
getScheduler
();
scheduler
.
start
();
return
scheduler
;
}
}
eladmin-system/src/main/java/me/zhengjie/modules/quartz/utils/QuartzManage.java
View file @
08f6c582
...
...
@@ -20,6 +20,7 @@ import me.zhengjie.exception.BadRequestException;
import
me.zhengjie.modules.quartz.domain.QuartzJob
;
import
org.quartz.*
;
import
org.quartz.impl.triggers.CronTriggerImpl
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
java.util.Date
;
...
...
@@ -35,7 +36,7 @@ public class QuartzManage {
private
static
final
String
JOB_NAME
=
"TASK_"
;
@Resource
(
name
=
"scheduler"
)
@Resource
private
Scheduler
scheduler
;
public
void
addJob
(
QuartzJob
quartzJob
){
...
...
Write
Preview
Supports
Markdown
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