当前位置:网站首页>Set when quartz scheduled task trigger starts
Set when quartz scheduled task trigger starts
2022-06-28 22:15:00 【Yuyy】
This paper is finally updated at 757 Days ago, , The information may have developed or changed .
demand
- In order to put the trigger's Cron Expressions in the database , Convenient maintenance . Therefore, you need to go to the database to get the data when the project is started Cron expression , And configure the trigger , Add to the scheduler .
Realization
- When configuring scheduled tasks Bean when , By setting
initMethod , Implementation configuration Bean Get from the database Cron expression . - Because it needs to be added
iniMethod , So you need to create a new class , InheritCronTriggerBean. - stay
iniMethod from the database Cron expression , And set it totriggerin .
<bean id="Task" class="xxx" >
</bean>
<bean id="TaskDetail"
class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject">
<ref bean="Task" />
</property>
<property name="targetMethod">
<value>exec</value>
</property>
</bean>
<!-- Trigger Cron The expression is obtained from the database at startup -->
<bean id="TaskTrigger" class="CronTriggerBean"
lazy-init="false" init-method="init">
<property name="jobDetail" ref="TaskDetail" />
</bean>public class CronTriggerBean extends CronTriggerBean{
public void init(){
String hql = "xxx";
List<TRetryCron> list = Dao.getHibernateTemplate().find(sb.toString());
String cronExpression=null;
if(null!=list&&list.size()>0){
cronExpression=list.get(0).getCCronExpression();
}else{
// Avoid failing to get... From the database Cron expression , Cause exception , Here's one that will never be implemented Cron expression
cronExpression="0 0 5 31 2 ?";
logger.error(" Failed to get a valid... From the database Cron expression .");
}
try {
super.setCronExpression(cronExpression);
} catch (ParseException e) {
logger.error(String.format(" analysis Cron Expression failed , Set a never executed Cron expression 【0 0 5 31 2 ?】, Failed parsing Cron Expression for 【%s】.", cronExpression));
// analysis Crontab Expression failed , Set a never executed Cron expression
try {
super.setCronExpression("0 0 5 31 2 ?");
} catch (ParseException e1) {
}
}
}
}Post Views: 312
边栏推荐
- [webapi] return dynamic list dynamic
- Webrtc audio and video development - experience
- 彪马携手10KTF Shop启动其迄今为止规模首屈一指的Web3合作项目
- 【selenium自动化过程中的api抓包】browsermobproxy的安装和配置
- 职业问诊 | 面试时被问到职业规划该怎么回答?
- CVPR 2022 𞓜 a creative and aesthetic text generation method! Support any input
- IDC:阿里云获2021中国数据治理平台市场份额第一
- 硬件开发笔记(七): 硬件开发基本流程,制作一个USB转RS232的模块(六):创建0603封装并关联原理图元器件
- 场景化接口开发利器,金蝶云苍穹新版OpenAPI引擎来了!
- 【电子实验2】简单电子门铃
猜你喜欢
![[width first search note] BFS output shortest path](/img/b5/553ca241ae571daecabd282f33f20a.jpg)
[width first search note] BFS output shortest path

Safety innovation practice | Haitai Fangyuan was invited to participate in the technical exchange Seminar on "network information innovation and value co creation in the digital age"

直播预告|SQL也能玩转工业级机器学习?MLOps meetup V3带你一探究竟!

F1tenth gym of ROS 2 humble hawksbill

Use of axurer9 master

Deploy grafana to realize graphical monitoring
![Sword finger offer:[day 2 linked list (simple)] --- > print the linked list from end to end](/img/d6/824985b74b27a1bee456c2cebbac26.jpg)
Sword finger offer:[day 2 linked list (simple)] --- > print the linked list from end to end

YAYA LIVE CTO 唐鸿斌:真正本地化,要让产品没有「产地」属性

After reading the list of global patent and chip buyers, I understand that high innovation can lead to high profits

Binomial distribution (a discrete distribution)
随机推荐
[dynamic programming] p1018 linear DP: maximum product
解读 | 数据分析的发展和演变都经过哪几个阶段?
Dart的类扩展、可选类型扩展
Binomial distribution (a discrete distribution)
运维体系建设思考 - 稳定性篇
构建实战化防御体系之立体防渗透
How to open a safe and reliable securities account in the financial management class of qiniu school?
Security dilemma of NFT liquidity agreement - Analysis of the hacked event of NFT loan agreement xcarnival
Appium automated test Jiugongge unlock
After easycvr creates a new user, the video access page cannot be clicked. Fix the problem
【电子实验2】简单电子门铃
Live broadcast preview | can SQL also play industrial machine learning? Mlops meetup V3 takes you to the bottom!
flutter通过 GlobalKey 获取界面任意元素坐标尺寸
PE file-
零基础自学SQL课程 | SQL中的日期函数大全
IPv6 comprehensive experiment
阿海的忠告
什么是低代码开发?
ROS 2 Humble Hawksbill 之 f1tenth gym
Akamai acquires linode