Spring provides a convenient Factorybean class for creating quartz scheduler, trigger, and jobdetail so that the benefits of injection can be enjoyed in the spring container. In addition, Spring provides some handy tool classes that directly package the beans in spring into legitimate tasks. Spring further reduces the difficulty of using quartz and can use quartz
In Java we often use timers and timertask to implement timing functions, but in a Java EE project, spring can be used to integrate the quartz timer, very powerful, able to achieve all the desired timing tasks, including the Tomcat server started to start, Regular fixed-point fixed weeks and so on, the introduction of quartz and time configuration on the internet has a lot of information, is not burdensome,
Preface
This article is a revision and supplement to the previous article Spring+springmvc+mybatis+quartz the Integration Code section, the biggest change is that the background frame becomes spring Boot.
The technology or tools used in this project are: Spring Boot Mybatis Quartz pagehelper vuejs elementui mysql database body configuration
In this case, we still use the MySQL database as the storage carri
Use declarative handling of software configurations as much as possible, followed by programmatic approaches. In the previous article, "Quartz Framework QuickStart (i)", if we were to change the execution time and frequency after the Job started, we had to modify the source code to recompile. This approach is only applicable to small example programs, but for a large and complex system, this becomes a problem. So, if you can deploy the quart Job decla
BeanID= "Myjobdetaila"class= "Org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> Propertyname= "TargetObject"ref= "Myjoba"> Property> Propertyname= "Targetmethod"value= "Work"> Property> Propertyname= "Concurrent"value= "false" /> whether the task is allowed to execute concurrently. When the value is false, it means that you must wait until the previous thread has finished processing before starting a new thread - Bean>4. Conf
Usage Environment: ECLIPSE+MAVEN+SPRING+QUARTZ1Use purpose: Perform the timer to complete the scan operation.Puzzle point: Using the QUARTZ2 version will appear inexplicable errors, similar to the interface and class definition of the difference. Look at the document and don't get it straight.
Use steps:
1. Configure the MAVEN profile (configured with the QUARTZ1 version), pom.xml add the code:
The code is as follows
Copy Code
2. Configure the Spring profile Spr
Sometimes our tasks (jobs) need to be completed before some tasks can be performed, such as when you bulk data from the old database, and you need to import data that is dependent on other data into the new database, and then import the relationship. In this case we can use quartz listener to make a fuss.
First we write a class of the main task, named Mainjob, and her role as a starting point for a series of tasks.
Mainjob.java
Package jobs;Import
Starting with the thread, let's look at the Quartzschedulerthread class (responsible for performing the work of the triggering trigger):
@Override public
Void Run () {
Boolean lastacquirefailed = false;
while (!halted.get ()) {
try {
//check if we ' re supposed to pause
... Synchronized (Siglock) {while
(paused !halted.get ()) {
try {
//wait until Togglepause
I do not know when you use the quartz is not encountered in such a situation:
Triggers are set to fire every 3 seconds, but the work takes 10 seconds to execute. Therefore, the trigger has missed the trigger before the end of a task execution
How do we deal with this situation, let's study ...
Or do you want to paste the code first:
Job class: Statefuldumbjob.java[Java] View plain copy importjava.text.simpledateformat; importjava.util.calendar; impor
Here are some instructions on Quartz time configuration:
Field Order
Allowed Values
special characters that are allowed
Seconds
0-59
, - * /
Part
0-59
, - * /
Hours
0-23
, - * /
Date
1-31
, - * ? /L W C
Month
1-12 or Jan-dec.
, - * /
Week
1-7 or Sun-sat.
SPRING3.0 does not support Quartz2.0 because Org.quartz.CronTrigger in 2.0 has changed from class to a interface to cause Incompatibleclasschangeerror errors:
caused By:java.lang.IncompatibleClassChangeError:class Org.springframework.scheduling.quartz.CronTriggerBean has Interface Org.quartz.CronTrigger as Super class
Today, I just downloaded Spring3.2.4 and found that this new version has already supported quartz2.x. Previous spring versions only support
Quartz is a powerful enterprise-level task scheduling framework that inherits and simplifies quartz in spring, and looks at how quartz is configured in spring:First, let's write a class that is scheduled:package Com.kay.quartz;Public class Quartzjob{public void work (){System.out.println ("Quartz Task Scheduler!!! ");}
Keep the quartz jobdetail,trigger to the database and find that the system error the job (Default.jobdetail) referenced by the trigger does not existIt has been tested that only spring's test environment is normal when not using Hibernate. And when put in the work environment, there is a mistake. So the suspicion is a datasource problem. The Spring Quartz Forum found this to be the problem. The DataSource o
We plan to use the latest SQLite version as the job store of quartz. net.
Add the following content to dbproviders. properties under quartz. impl. adojobstore. Common:
# SQLite 1.0.61.0 + ado net provider for SQLite# Driver can be found at: http://sqlite.phxsoftware.comQuartz. dbprovider. SQLite-106.assemblyName = system. Data. SQLite, version = 1.0.61.0, culture = neutral, publickeytoken = db937bc2d44ff
About quartz. net
Quartz. NET is an open-source job scheduling framework on the. NET platform. It is first transplanted from quartz on the Java platform. The official website is http://quartznet.sourceforge.net/. the latest website is 1.0.3. It can be applied to winform programs and Asp.net programs. Job Scheduling can be understood as a scheduled task. For examp
Http://www.cnblogs.com/kay/archive/2007/11/02/947372.htmlIssues that a message or task sends or executes more than once:1.2. Separate the quartz configuration to prevent Tomcat from loading spring.Specific practices: http://blog.csdn.net/zhujianpengzha/article/details/8140442When using Spring's quartz timer recently, it was found that the task was always repeated two times after the time, under Tomcat or JB
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.