Scheduler scheduled scheduling system is required by most industrial projects. The traditional Spring-job mode is out of date, because there are many problems, especially the appending, modification and deletion of scheduled scheduling. XML needs to be modified. The configuration of XML takes effect only through hot deployment of grayscale publishing scheme or directly stopping or restarting the server, which cannot be automatically started or repaired.

Note: The application can be deployed in a cluster, and the application can be configured in a cluster or a single side. Today, we will explain how to use Spring4 + Scheduler to realize scheduling.

1. Add the Quartz JAR package to the project’s POM.xml file as follows:

Java code





lt; dependency>

org.quartz-scheduler

quartz

1.8.5

lt; /dependency>

2. Define the quartz configuration file spring-context-quartz.

Java code





xmlns:context=”http://www.springframework.org/schema/context”xsi:schemaLocation=”

http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd

http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd”

default-lazy-init=”false”>

3. Add the spring-context-Quartz. XML configuration file to the web

Java code





4. Define the Job entity object

Java code











5. Quartz jobServvice class

Java code

















6. I will not write Controller, DAO and dao.xml related to job. In fact, it is the operation of adding, deleting, modifying and checking data

7. Start the project to verify the success of Quartz:

Project startup console:














Willing to understand the framework technology or source code of friends directly ask to exchange technology: 2042849237

Some distributed solutions, friends who are willing to understand can find our team to discuss

More detailed source code reference source: minglisoft.cn/technology