`
kevin19900306
  • 浏览: 448629 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论

Spring与Quartz的整合实现定时任务调度

阅读更多
最近在研究Spring中的定时任务功能,最好的办法当然是使用Quartz来实现。对于一个新手来说,花了我不少时间,这里我写个笔记,给大家参考。
我使用的是Maven来管理项目,需要的Jar包我给大家贴出来。

quartz-1.8.5.jar
commons-logging.jar
spring-core-3.0.5.RELEASE.jar
spring-beans-3.0.5.RELEASE.jar
spring-context-3.0.5.RELEASE.jar
spring-context-support-3.0.5.RELEASE.jar
spring-asm-3.0.5.RELEASE.jar
spring-expression-3.0.5.RELEASE.jar
spring.transaction-3.0.5.RELEASE.jar
spring-web-3.0.5.RELEASE.jar

Maven的pom.xml的配置:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>QtzTest</groupId>
    <artifactId>QtzTest</artifactId>
    <version>1.0</version>

    <properties>
        <springframework.version>3.0.5.RELEASE</springframework.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${springframework.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context-support</artifactId>
            <version>${springframework.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
            <version>${springframework.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${springframework.version}</version>
        </dependency>

        <dependency>
            <groupId>org.quartz-scheduler</groupId>
            <artifactId>quartz</artifactId>
            <version>1.8.5</version>
        </dependency>
    </dependencies>

    <build>
        <finalName>${project.artifactId}</finalName>
        <plugins>
            <plugin>
                <groupId>org.mortbay.jetty</groupId>
                <artifactId>jetty-maven-plugin</artifactId>
                <version>7.5.4.v20111024</version>
                <configuration>
                    <scanIntervalSeconds>10</scanIntervalSeconds>
                    <webApp>
                        <contextPath>/${project.artifactId}</contextPath>
                    </webApp>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

特别注意一点,与Spring3.1以下版本整合必须使用Quartz1,最初我拿2.1.3的,怎么搞都报错:
Caused by: org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [org.springframework.scheduling.quartz.CronTriggerBean] for bean with name 'mytrigger' defined in class path resource [applicationContext.xml]: problem with class file or dependent class; nested exception is java.lang.IncompatibleClassChangeError: class org.springframework.scheduling.quartz.CronTriggerBean has interface org.quartz.CronTrigger as super class

查看发现spring3.0.5中org.springframework.scheduling.quartz.CronTriggerBean继承了org.quartz.CronTrigger(public class CronTriggerBeanextends CronTrigger),而在quartz2.1.3中org.quartz.CronTrigger是个接口(publicabstract interface CronTrigger extends Trigger),而在quartz1.8.5及1.8.4中org.quartz.CronTrigger是个类(publicclass CronTrigger extends Trigger),从而造成无法在applicationContext中配置触发器。这是spring3.1以下版本和quartz2版本不兼容的一个bug。(感谢tiren的回复,spring3.1以及以后版本支持quartz2)

在Spring中使用Quartz有两种方式实现:第一种是任务类继承QuartzJobBean,第二种则是在配置文件里定义任务类和要执行的方法,类和方法仍然是普通类。很显然,第二种方式远比第一种方式来的灵活。

第一种方式的JAVA代码:
package com.ncs.hj;

import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.scheduling.quartz.QuartzJobBean;

public class SpringQtz extends QuartzJobBean{
	private static int counter = 0;
	protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
		System.out.println();
		long ms = System.currentTimeMillis();
		System.out.println("\t\t" + new Date(ms));
		System.out.println(ms);
		System.out.println("(" + counter++ + ")");
		String s = (String) context.getMergedJobDataMap().get("service");
		System.out.println(s);
		System.out.println();
	}
}

第二种方式的JAVA代码:
package com.ncs.hj;

import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.scheduling.quartz.QuartzJobBean;

import java.util.Date;

public class SpringQtz {
	private static int counter = 0;
	protected void execute()  {
		long ms = System.currentTimeMillis();
		System.out.println("\t\t" + new Date(ms));
		System.out.println("(" + counter++ + ")");
	}
}

Spring的配置文件:
    <!------------ 配置调度程序quartz ,其中配置JobDetail有两种方式-------------->  
        <!--方式一:使用JobDetailBean,任务类必须实现Job接口 -->   
        <bean id="myjob" class="org.springframework.scheduling.quartz.JobDetailBean">  
         <property name="name" value="exampleJob"></property>  
         <property name="jobClass" value="com.ncs.hj.SpringQtz"></property> 
         <property name="jobDataAsMap">
				<map>
					<entry key="service"><value>simple is the beat</value></entry>
				</map>
	</property>
        </bean> 
        <!--运行时请将方式一注释掉! -->  
        <!-- 方式二:使用MethodInvokingJobDetailFactoryBean,任务类可以不实现Job接口,通过targetMethod指定调用方法-->  
        <!-- 定义目标bean和bean中的方法 -->
        <bean id="SpringQtzJob" class="com.ncs.hj.SpringQtz"/>
        <bean id="SpringQtzJobMethod" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
        <property name="targetObject">
            <ref bean="SpringQtzJob"/>
        </property>
        <property name="targetMethod">  <!-- 要执行的方法名称 -->
            <value>execute</value>
        </property>
    </bean>

    <!-- ======================== 调度触发器 ======================== -->
    <bean id="CronTriggerBean" class="org.springframework.scheduling.quartz.CronTriggerBean">
        <property name="jobDetail" ref="SpringQtzJobMethod"></property>
        <property name="cronExpression" value="0/5 * * * * ?"></property>
    </bean>

    <!-- ======================== 调度工厂 ======================== -->
    <bean id="SpringJobSchedulerFactoryBean" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
        <property name="triggers">
            <list>
                <ref bean="CronTriggerBean"/>
            </list>
        </property>
    </bean>  

关于cronExpression表达式,这里讲解一下:
字段 允许值 允许的特殊字符
秒 0-59 , - * /
分 0-59 , - * /
小时 0-23 , - * /
日期 1-31 , - * ? / L W C
月份 1-12 或者 JAN-DEC , - * /
星期 1-7 或者 SUN-SAT , - * ? / L C #
年(可选) 留空, 1970-2099 , - * /
表达式意义
"0 0 12 * * ?" 每天中午12点触发
"0 15 10 ? * *" 每天上午10:15触发
"0 15 10 * * ?" 每天上午10:15触发
"0 15 10 * * ? *" 每天上午10:15触发
"0 15 10 * * ? 2005" 2005年的每天上午10:15触发
"0 * 14 * * ?" 在每天下午2点到下午2:59期间的每1分钟触发
"0 0/5 14 * * ?" 在每天下午2点到下午2:55期间的每5分钟触发
"0 0/5 14,18 * * ?" 在每天下午2点到2:55期间和下午6点到6:55期间的每5分钟触发
"0 0-5 14 * * ?" 在每天下午2点到下午2:05期间的每1分钟触发
"0 10,44 14 ? 3 WED" 每年三月的星期三的下午2:10和2:44触发
"0 15 10 ? * MON-FRI" 周一至周五的上午10:15触发
"0 15 10 15 * ?" 每月15日上午10:15触发
"0 15 10 L * ?" 每月最后一日的上午10:15触发
"0 15 10 ? * 6L" 每月的最后一个星期五上午10:15触发
"0 15 10 ? * 6L 2002-2005" 2002年至2005年的每月的最后一个星期五上午10:15触发
"0 15 10 ? * 6#3" 每月的第三个星期五上午10:15触发
每天早上6点
0 6 * * *
每两个小时
0 */2 * * *
晚上11点到早上8点之间每两个小时,早上八点
0 23-7/2,8 * * *
每个月的4号和每个礼拜的礼拜一到礼拜三的早上11点
0 11 4 * 1-3
1月1日早上4点
0 4 1 1 *

最后别忘了在web.xml里面配置Spring:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
		  http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
         version="2.5">
    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
    </welcome-file-list>

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/spring-config.xml</param-value>
    </context-param>

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
</web-app>

运行结果:
Wed Feb 08 13:58:30 CST 2012
(0)
Wed Feb 08 13:58:35 CST 2012
(1)
Wed Feb 08 13:58:40 CST 2012
(2)
Wed Feb 08 13:58:45 CST 2012
(3)
Wed Feb 08 13:58:50 CST 2012
(4)
Wed Feb 08 13:58:55 CST 2012
(5)
Wed Feb 08 13:59:00 CST 2012
(6)
分享到:
评论
43 楼 还没有注册吗 2016-10-27  
[i][i][i][i][i][i][i][i][i][i][i][i][i][i][i][i][i][i][i][i][i][i][i][i][i][i][i][i][i][i][i][i][i][i][b][b][b]
[flash=200,200][url][img][list]
[*]
引用
[/list][/img][/url][/flash]
[/b][/b][/b][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i]
42 楼 dongdong5712 2016-05-16  
晚上11点到早上8点之间每两个小时,早上八点
0 23-7/2,8 * * *
每个月的4号和每个礼拜的礼拜一到礼拜三的早上11点
0 11 4 * 1-3

以上一段应该不对吧?
41 楼 sunny_javajava 2016-05-12  
非常感谢楼主!
你的项目如果是spring2,使用quartz-1.8.5.jar还会报以下错误:
Error creating bean with name 'SpringJobSchedulerFactoryBean'

解决方法:
删除quartz-1.8.5.jar,从Spring2.0的发布包中,spring-framework-2.0.8\lib\quartz目录下,复制quartz-all-1.6.0.jar到项目的lib中,重新发布项目,启动后,一切ok!

开源项目容易出现包冲突的问题,如果你的项目使用spring2,那么,使用的包就从Spring2.0的发布包中复制,这样好多问题都可以解决,
没有必要从源网站上下载,不是版本越新越好的。
40 楼 fuyangz 2016-05-05  
不知道为什么。
39 楼 fuyangz 2016-05-05  
spring-context-support-3.2.3.RELEASE.jar [size=xx-small][/size]
38 楼 fuyangz 2016-05-05  
[color=blue][/co[size=xx-large][/size]lor]qqq
37 楼 张文军 2015-11-10  
36 楼 lghan 2015-11-09  
方法1可以注入service,方法2怎么注入啊?

方法1设置concurrent属性运行报错
35 楼 wangyonglin1123 2015-09-10  
可以的 jar包下载地址
博主jar包下载地址
http://download.csdn.net/detail/wangyonglin1123/9096077
也可以发邮件向我索要:775048682@qq.com
34 楼 wangyonglin1123 2015-09-10  
可以的 jar包下载地址 
博主jar包下载地址
http://download.csdn.net/detail/wangyonglin1123/9096077
也可以发邮件向我索要:775048682@qq.com
33 楼 msqxhl 2015-09-08  
11楼的答案是非常正确的。我是spring4.0,加quartz1.8,老子找了弄了两天都报错,仔细看了11楼的答案正确了。
32 楼 wangyonglin1123 2015-09-05  
nested exception is java.lang.NoClassDefFoundError: org/quartz/JobDetail

各位大神这个是很么原因
31 楼 wangyonglin1123 2015-09-05  
2015-9-5 0:19:16 org.apache.tomcat.util.digester.SetPropertiesRule begin
警告: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.j2ee.server:test' did not find a matching property.
2015-9-5 0:19:16 org.apache.catalina.core.AprLifecycleListener init
信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: D:\工作\工具大全\plantix\PlantixStudio2.0\jre\bin;.;C:\windows\Sun\Java\bin;C:\windows\system32;C:\windows;D:\工作\工具大全\plantix\PlantixStudio2.0\jre\bin;D:/工作/工具大全/plantix/PlantixStudio2.0/jre/bin/client;D:/工作/工具大全/plantix/PlantixStudio2.0/jre/bin;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files (x86)\Common Files\lenovo\easyplussdk\bin;C:\ProgramData\Lenovo\ReadyApps;C:\Program Files\Java\jdk1.6.0_43\bin;C:\Program Files\Java\jdk1.6.0_43\jre\bin;:C:\软件\tomcat7\apache-tomcat-7.0.40-windows-x64\apache-tomcat-7.0.40/common/lib;
2015-9-5 0:19:16 org.apache.coyote.http11.Http11Protocol init
信息: Initializing Coyote HTTP/1.1 on http-8080
2015-9-5 0:19:16 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 513 ms
2015-9-5 0:19:16 org.apache.catalina.core.StandardService start
信息: Starting service Catalina
2015-9-5 0:19:16 org.apache.catalina.core.StandardEngine start
信息: Starting Servlet Engine: Apache Tomcat/6.0.20
2015-9-5 0:19:17 org.apache.catalina.loader.WebappClassLoader validateJarFile
信息: validateJarFile(D:\工作\工具大全\plantix\PlantixStudio2.0\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp4\wtpwebapps\test\WEB-INF\lib\j2ee.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
2015-9-5 0:19:18 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring root WebApplicationContext
2015-09-05 00:19:18,316 [main] INFO  org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization started
2015-09-05 00:19:18,397 [main] INFO  org.springframework.web.context.support.XmlWebApplicationContext - Refreshing Root WebApplicationContext: startup date [Sat Sep 05 00:19:18 CST 2015]; root of context hierarchy
2015-09-05 00:19:18,554 [main] INFO  org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [applicationContext.xml]
2015-09-05 00:19:20,038 [main] INFO  org.springframework.beans.factory.support.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@148ccb8: defining beans [job2,simpleTrigger,org.springframework.scheduling.quartz.SchedulerFactoryBean#0]; root of factory hierarchy
2015-09-05 00:19:20,246 [main] INFO  org.springframework.beans.factory.support.DefaultListableBeanFactory - Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@148ccb8: defining beans [job2,simpleTrigger,org.springframework.scheduling.quartz.SchedulerFactoryBean#0]; root of factory hierarchy
2015-09-05 00:19:20,246 [main] ERROR org.springframework.web.context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'job2' defined in class path resource [applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/quartz/JobDetail
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:546)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:872)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:423)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3934)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4429)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:722)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:583)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: java.lang.NoClassDefFoundError: org/quartz/JobDetail
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
at java.lang.Class.getDeclaredMethods(Class.java:1791)
at java.beans.Introspector$1.run(Introspector.java:1287)
at java.security.AccessController.doPrivileged(Native Method)
at java.beans.Introspector.getPublicDeclaredMethods(Introspector.java:1285)
at java.beans.Introspector.getTargetMethodInfo(Introspector.java:1151)
at java.beans.Introspector.getBeanInfo(Introspector.java:402)
at java.beans.Introspector.getBeanInfo(Introspector.java:168)
at org.springframework.beans.CachedIntrospectionResults.<init>(CachedIntrospectionResults.java:224)
at org.springframework.beans.CachedIntrospectionResults.forClass(CachedIntrospectionResults.java:145)
at org.springframework.beans.BeanWrapperImpl.getCachedIntrospectionResults(BeanWrapperImpl.java:305)
at org.springframework.beans.BeanWrapperImpl.getPropertyDescriptorInternal(BeanWrapperImpl.java:335)
at org.springframework.beans.BeanWrapperImpl.isWritableProperty(BeanWrapperImpl.java:407)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1319)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1076)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
... 26 more
Caused by: java.lang.ClassNotFoundException: org.quartz.JobDetail
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1387)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
... 43 more
2015-9-5 0:19:20 org.apache.catalina.core.StandardContext listenerStart
严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'job2' defined in class path resource [applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/quartz/JobDetail
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:546)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:872)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:423)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3934)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4429)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:722)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:583)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: java.lang.NoClassDefFoundError: org/quartz/JobDetail
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
at java.lang.Class.getDeclaredMethods(Class.java:1791)
at java.beans.Introspector$1.run(Introspector.java:1287)
at java.security.AccessController.doPrivileged(Native Method)
at java.beans.Introspector.getPublicDeclaredMethods(Introspector.java:1285)
at java.beans.Introspector.getTargetMethodInfo(Introspector.java:1151)
at java.beans.Introspector.getBeanInfo(Introspector.java:402)
at java.beans.Introspector.getBeanInfo(Introspector.java:168)
at org.springframework.beans.CachedIntrospectionResults.<init>(CachedIntrospectionResults.java:224)
at org.springframework.beans.CachedIntrospectionResults.forClass(CachedIntrospectionResults.java:145)
at org.springframework.beans.BeanWrapperImpl.getCachedIntrospectionResults(BeanWrapperImpl.java:305)
at org.springframework.beans.BeanWrapperImpl.getPropertyDescriptorInternal(BeanWrapperImpl.java:335)
at org.springframework.beans.BeanWrapperImpl.isWritableProperty(BeanWrapperImpl.java:407)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1319)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1076)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
... 26 more
Caused by: java.lang.ClassNotFoundException: org.quartz.JobDetail
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1387)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
... 43 more
2015-9-5 0:19:20 org.apache.catalina.core.StandardContext start
严重: Error listenerStart
2015-9-5 0:19:20 org.apache.catalina.core.StandardContext start
严重: Context [/test] startup failed due to previous errors
2015-9-5 0:19:20 org.apache.catalina.core.ApplicationContext log
信息: Closing Spring root WebApplicationContext
2015-9-5 0:19:20 org.apache.coyote.http11.Http11Protocol start
信息: Starting Coyote HTTP/1.1 on http-8080
2015-9-5 0:19:20 org.apache.jk.common.ChannelSocket init
信息: JK: ajp13 listening on /0.0.0.0:8009
2015-9-5 0:19:20 org.apache.jk.server.JkMain start
信息: Jk running ID=0 time=0/32  config=null
2015-9-5 0:19:20 org.apache.catalina.startup.Catalina start
信息: Server startup in 3850 ms
30 楼 wangyonglin1123 2015-09-05  
2015-9-5 0:17:39 org.apache.tomcat.util.digester.SetPropertiesRule begin
警告: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.j2ee.server:test' did not find a matching property.
2015-9-5 0:17:39 org.apache.catalina.core.AprLifecycleListener init
信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: D:\工作\工具大全\plantix\PlantixStudio2.0\jre\bin;.;C:\windows\Sun\Java\bin;C:\windows\system32;C:\windows;D:\工作\工具大全\plantix\PlantixStudio2.0\jre\bin;D:/工作/工具大全/plantix/PlantixStudio2.0/jre/bin/client;D:/工作/工具大全/plantix/PlantixStudio2.0/jre/bin;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files (x86)\Common Files\lenovo\easyplussdk\bin;C:\ProgramData\Lenovo\ReadyApps;C:\Program Files\Java\jdk1.6.0_43\bin;C:\Program Files\Java\jdk1.6.0_43\jre\bin;:C:\软件\tomcat7\apache-tomcat-7.0.40-windows-x64\apache-tomcat-7.0.40/common/lib;
2015-9-5 0:17:39 org.apache.coyote.http11.Http11Protocol init
信息: Initializing Coyote HTTP/1.1 on http-8080
2015-9-5 0:17:39 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 789 ms
2015-9-5 0:17:39 org.apache.catalina.core.StandardService start
信息: Starting service Catalina
2015-9-5 0:17:39 org.apache.catalina.core.StandardEngine start
信息: Starting Servlet Engine: Apache Tomcat/6.0.20
2015-9-5 0:17:43 org.apache.catalina.loader.WebappClassLoader validateJarFile
信息: validateJarFile(D:\工作\工具大全\plantix\PlantixStudio2.0\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp4\wtpwebapps\test\WEB-INF\lib\j2ee.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
2015-9-5 0:17:44 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring root WebApplicationContext
2015-09-05 00:17:44,175 [main] INFO  org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization started
2015-09-05 00:17:44,240 [main] INFO  org.springframework.web.context.support.XmlWebApplicationContext - Refreshing Root WebApplicationContext: startup date [Sat Sep 05 00:17:44 CST 2015]; root of context hierarchy
2015-09-05 00:17:44,396 [main] INFO  org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [applicationContext.xml]
2015-09-05 00:17:45,396 [main] INFO  org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [applicationContext-dataSource.xml]
2015-09-05 00:17:45,588 [main] INFO  org.springframework.beans.factory.support.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1dc049d: defining beans [plantix.core.spring.suport.factory.BeanFactoryUtils#0,job2,simpleTrigger,org.springframework.scheduling.quartz.SchedulerFactoryBean#0]; root of factory hierarchy
2015-09-05 00:17:45,666 [main] INFO  org.springframework.beans.factory.support.DefaultListableBeanFactory - Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1dc049d: defining beans [plantix.core.spring.suport.factory.BeanFactoryUtils#0,job2,simpleTrigger,org.springframework.scheduling.quartz.SchedulerFactoryBean#0]; root of factory hierarchy
2015-09-05 00:17:45,666 [main] ERROR org.springframework.web.context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'job2' defined in class path resource [applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/quartz/JobDetail
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:546)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:872)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:423)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3934)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4429)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:722)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:583)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: java.lang.NoClassDefFoundError: org/quartz/JobDetail
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
at java.lang.Class.getDeclaredMethods(Class.java:1791)
at java.beans.Introspector$1.run(Introspector.java:1287)
at java.security.AccessController.doPrivileged(Native Method)
at java.beans.Introspector.getPublicDeclaredMethods(Introspector.java:1285)
at java.beans.Introspector.getTargetMethodInfo(Introspector.java:1151)
at java.beans.Introspector.getBeanInfo(Introspector.java:402)
at java.beans.Introspector.getBeanInfo(Introspector.java:168)
at org.springframework.beans.CachedIntrospectionResults.<init>(CachedIntrospectionResults.java:224)
at org.springframework.beans.CachedIntrospectionResults.forClass(CachedIntrospectionResults.java:145)
at org.springframework.beans.BeanWrapperImpl.getCachedIntrospectionResults(BeanWrapperImpl.java:305)
at org.springframework.beans.BeanWrapperImpl.getPropertyDescriptorInternal(BeanWrapperImpl.java:335)
at org.springframework.beans.BeanWrapperImpl.isWritableProperty(BeanWrapperImpl.java:407)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1319)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1076)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
... 26 more
Caused by: java.lang.ClassNotFoundException: org.quartz.JobDetail
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1387)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
... 43 more
2015-9-5 0:17:45 org.apache.catalina.core.StandardContext listenerStart
严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'job2' defined in class path resource [applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/quartz/JobDetail
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:546)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:872)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:423)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3934)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4429)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:722)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:583)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: java.lang.NoClassDefFoundError: org/quartz/JobDetail
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
at java.lang.Class.getDeclaredMethods(Class.java:1791)
at java.beans.Introspector$1.run(Introspector.java:1287)
at java.security.AccessController.doPrivileged(Native Method)
at java.beans.Introspector.getPublicDeclaredMethods(Introspector.java:1285)
at java.beans.Introspector.getTargetMethodInfo(Introspector.java:1151)
at java.beans.Introspector.getBeanInfo(Introspector.java:402)
at java.beans.Introspector.getBeanInfo(Introspector.java:168)
at org.springframework.beans.CachedIntrospectionResults.<init>(CachedIntrospectionResults.java:224)
at org.springframework.beans.CachedIntrospectionResults.forClass(CachedIntrospectionResults.java:145)
at org.springframework.beans.BeanWrapperImpl.getCachedIntrospectionResults(BeanWrapperImpl.java:305)
at org.springframework.beans.BeanWrapperImpl.getPropertyDescriptorInternal(BeanWrapperImpl.java:335)
at org.springframework.beans.BeanWrapperImpl.isWritableProperty(BeanWrapperImpl.java:407)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1319)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1076)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
... 26 more
Caused by: java.lang.ClassNotFoundException: org.quartz.JobDetail
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1387)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
... 43 more
2015-9-5 0:17:45 org.apache.catalina.core.StandardContext start
严重: Error listenerStart
2015-9-5 0:17:45 org.apache.catalina.core.StandardContext start
严重: Context [/test] startup failed due to previous errors
2015-9-5 0:17:45 org.apache.catalina.core.ApplicationContext log
信息: Closing Spring root WebApplicationContext
2015-9-5 0:17:45 org.apache.coyote.http11.Http11Protocol start
信息: Starting Coyote HTTP/1.1 on http-8080
2015-9-5 0:17:46 org.apache.jk.common.ChannelSocket init
信息: JK: ajp13 listening on /0.0.0.0:8009
2015-9-5 0:17:46 org.apache.jk.server.JkMain start
信息: Jk running ID=0 time=0/62  config=null
2015-9-5 0:17:46 org.apache.catalina.startup.Catalina start
信息: Server startup in 6311 ms
29 楼 小高你好 2015-08-20  
你好,我看了你的这个博客,不过我有一点不知道,你怎么设置 它的暂停任务????
28 楼 ccnu_ouy520 2014-11-17  
如果是能用数据库 的就用数据库。
27 楼 ccnu_ouy520 2014-11-17  
都可以,数据库 job 其实也不错,最近一个 项目  就用的数据库任务 。
我们用的是mysql
26 楼 colin1210 2014-10-30  
参考http://nesuk.iteye.com/blog/1582557
25 楼 colin1210 2014-10-30  
xuewei2007 写道
楼主,我项目中也用spring+quartz来作定时任务调度的。。。
我设置的定时器表达式是:0 0/10 1-12 * * ?
因为我有个程序跑,需要另外一个系统给我数据,但是这个系统数据返回的时间不确定。。。所以我设置这么个定时任务,在每天凌晨1点到12点,每隔10分钟轮训一次。。。。

现在的问题是:我发现如果我再2点10分轮询到数据返回后,我启动我执行任务。。。但是我2点20分我的定时又会调度一次。。。。这种有什么好的办法解决?

applicationContext.xml中jobDetail bean添加如下配置,应该就可以了
<!--将并发设置为false--> 
    <property name="concurrent" value="false" /> 

试试,应该能解决你的问题
24 楼 xuewei2007 2014-07-11  
楼主,我项目中也用spring+quartz来作定时任务调度的。。。
我设置的定时器表达式是:0 0/10 1-12 * * ?
因为我有个程序跑,需要另外一个系统给我数据,但是这个系统数据返回的时间不确定。。。所以我设置这么个定时任务,在每天凌晨1点到12点,每隔10分钟轮训一次。。。。

现在的问题是:我发现如果我再2点10分轮询到数据返回后,我启动我执行任务。。。但是我2点20分我的定时又会调度一次。。。。这种有什么好的办法解决?

相关推荐

    spring整合quartz定时任务调度

    Spring框架作为Java领域广泛使用的轻量级框架,提供了与第三方库Quartz的整合,使得开发者能够轻松地在Spring应用中实现复杂的定时任务调度。Quartz是一款开源的作业调度框架,支持丰富的调度策略,可以满足各种定时...

    SpringBoot 整合Quartz(集群)实现定时任务调度

    SpringBoot整合Quartz实现定时任务调度是企业级应用中常见的需求,主要用于自动化执行某些周期性的任务,例如数据备份、报表生成、系统维护等。Quartz是一个功能强大的开源作业调度框架,能够灵活地定义任务和调度...

    Springboot整合Quartz实现定时任务数据库动态配置

    Spring Boot作为一个轻量级的Java框架,提供了与各种定时任务库集成的能力,其中Quartz是一个广泛应用的开源作业调度框架。本篇文章将详细探讨如何在Spring Boot项目中整合Quartz,并通过MySQL数据库实现定时任务的...

    quartz整合springbatch动态集群定时实现mysql参考

    在这个“quartz_springbatch_dynamic”项目中,我们将看到如何将这两个强大的工具结合起来,以实现动态集群环境中的定时任务执行,并使用MySQL作为数据存储。 Quartz是一个开源的作业调度框架,允许开发者创建、...

    spring+quartz动态定时任务创建 +mybatis

    当结合Quartz,一个强大的任务调度库,我们可以实现动态的定时任务创建,这在业务逻辑中有着广泛的应用,如数据同步、定时报表生成等。 **Spring框架** Spring框架是Java开发者必备的工具之一。它提供了一个统一的...

    Spring整合Quartz后的简单定时任务示例

    总结来说,这个资源为你提供了一个基础的Spring与Quartz集成案例,通过学习和实践,你可以掌握如何在Spring环境中利用Quartz实现高效、灵活的定时任务管理。同时,它也鼓励开发者之间的分享和交流,共同提升技术能力...

    java中spring与Quartz 整合定时任务.pdf

    在Java开发中,Spring框架和Quartz库的整合是实现定时任务的一种常见方式。Spring提供了灵活的定时任务支持,而Quartz则是一个强大的作业调度框架,可以用来安排复杂的任务执行计划。下面我们将深入探讨如何在Spring...

    Spring quartz 定时任务调度

    Spring Quartz 是一个强大的开源任务调度框架,它允许开发者在Java应用程序中定义和执行定时任务。在Spring框架中集成Quartz,可以充分利用Spring的IoC(Inversion of Control)和AOP(Aspect Oriented Programming...

    springboot整合quartz定时任务yml文件配置方式

    在Spring Boot应用中整合Quartz定时任务是一种常见的需求,它可以帮助我们执行周期性的后台任务,如数据同步、报表生成等。Spring Boot与Quartz的结合提供了便捷的配置方式,特别是通过YAML(YAML Ain't Markup ...

    Spring整合任务调度框架Quartz

    在本文中,我们将详细介绍如何将 Spring 整合任务调度框架 Quartz,从而实现任务调度的自动化。 一、使用配置文件方式整合 Quartz 在 Spring 中,可以使用配置文件方式来整合 Quartz。这种方式非常简单,开发者只...

    Spring 3整合Quartz 1.8实现定时任务三:动态暂停 恢复 修改和删除任务

    Spring 3整合Quartz 1.8实现定时任务三:动态暂停 恢复 修改和删除任务 任务保存到数据库,系统启动时读取数据库,页面显示加载,并管理 注:spring3+quartz2动态任务调度,任务保存在内存中,页面显示动态管理版...

    Spring3整合Quartz 2实现定时任务

    本文将深入探讨如何在Spring 3中整合Quartz 2来实现灵活、可扩展的定时任务系统。 首先,我们要了解Spring 3与Quartz 2的基本概念。Spring 3是Spring框架的一个版本,它提供了诸如依赖注入、面向切面编程、数据访问...

    Spring整合quartz2.2.3总结,quartz动态定时任务,Quartz定时任务集群配置

    Spring整合Quartz 2.2.3是...总之,Spring与Quartz的整合使得我们能够便捷地在Spring应用中实现复杂的定时任务管理。通过深入理解Quartz的工作原理和Spring的整合机制,开发者可以更好地控制和扩展应用的定时任务功能。

    spring+quartz实现动态设置定时任务

    5. **监控与管理**:为了更好地管理和监控定时任务,可以利用Quartz提供的JMX支持,或者使用第三方的监控工具,如Spring Boot Actuator,实时查看任务状态和执行情况。 6. **心得分享**:在实践中,要注意任务的...

    spring整合quartz动态定时任务demo-spring-quartz-demo.zip

    这个"spring-quartz-demo"项目就是一个很好的示例,它展示了如何在Spring中整合Quartz以实现动态定时任务。 首先,我们要了解Spring和Quartz的基本概念。Spring是一个全面的Java企业级应用开发框架,它提供了依赖...

    转:spring多个定时任务quartz配置

    在Spring框架中,Quartz是一个强大的任务调度库,可以用于...总之,Spring与Quartz的整合提供了灵活且强大的定时任务解决方案,适用于各种复杂的调度需求。正确配置和使用,能够帮助我们构建高效、可靠的后台任务系统。

    java中spring与Quartz 整合定时任务.docx

    在Java开发中,Spring框架和Quartz库的整合是实现定时任务的常见方法。Spring提供了对Quartz的集成,使得我们可以方便地在Spring应用上下文中配置和管理定时任务。下面将详细解释如何在Spring中整合Quartz以及相关的...

    quartz整合springbatch定时集群实现mysql参考模版

    将Quartz与SpringBatch整合,可以利用Quartz的定时功能触发SpringBatch的任务执行。首先,你需要在Spring配置中声明一个QuartzScheduler,并设置JobStore类型为支持集群的JDBCJobStore。接着,定义一个SpringBatch的...

    spring整合quartz定时任务

    Spring整合Quartz定时任务是企业级应用中常见的一种任务调度技术,它允许开发者在应用程序中设置定时执行的任务,比如数据同步、报表生成等。Quartz是一个功能强大的开源作业调度框架,而Spring则是一个广泛使用的...

Global site tag (gtag.js) - Google Analytics