`

spring+quartz

 
阅读更多

1.pom.xml

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

 

		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-context-support</artifactId>
			<version>4.0.3.RELEASE</version>
		</dependency>

 

 

当spring的版本为4.1.1.RELEASE时,quartz为1.7.3时,项目启动会报错

2015-08-17 17:38:11,919  WARN (org.springframework.web.context.support.XmlWebApplicationContext:487) - Exception encountered during context initialization - cancelling refresh attempt
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'callRecordController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.manyi.iw.agent.saleapp.service.CallRecordService com.manyi.iw.agent.saleapp.controller.call.CallRecordController.callRecordService; nested exception is java.lang.NoClassDefFoundError: org/quartz/impl/JobDetailImpl
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1204)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:538)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:229)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:725)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
	at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:663)
	at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:629)
	at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:677)
	at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:548)
	at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:489)
	at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
	at javax.servlet.GenericServlet.init(GenericServlet.java:158)
	at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1231)
	at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1144)
	at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1031)
	at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4914)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5201)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
	at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1648)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)
	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
	at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
	at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:463)
	at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:413)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)
	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
	at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
	at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1487)
	at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:97)
	at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1328)
	at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1420)
	at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:848)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:322)
	at sun.rmi.transport.Transport$1.run(Transport.java:177)
	at sun.rmi.transport.Transport$1.run(Transport.java:174)
	at java.security.AccessController.doPrivileged(Native Method)
	at sun.rmi.transport.Transport.serviceCall(Transport.java:173)
	at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:556)
	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:811)
	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:670)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.manyi.iw.agent.saleapp.service.CallRecordService com.manyi.iw.agent.saleapp.controller.call.CallRecordController.callRecordService; nested exception is java.lang.NoClassDefFoundError: org/quartz/impl/JobDetailImpl
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:555)
	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
	... 63 more
Caused by: java.lang.NoClassDefFoundError: org/quartz/impl/JobDetailImpl
	at java.lang.Class.getDeclaredMethods0(Native Method)
	at java.lang.Class.privateGetDeclaredMethods(Class.java:2570)
	at java.lang.Class.getDeclaredMethods(Class.java:1855)
	at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:571)
	at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:490)
	at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:474)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:241)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineConstructorsFromBeanPostProcessors(AbstractAutowireCapableBeanFactory.java:1059)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1032)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getSingletonFactoryBeanForTypeCheck(AbstractAutowireCapableBeanFactory.java:861)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryBean(AbstractAutowireCapableBeanFactory.java:791)
	at org.springframework.beans.factory.support.AbstractBeanFactory.isTypeMatch(AbstractBeanFactory.java:541)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:406)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:381)
	at org.springframework.beans.factory.BeanFactoryUtils.beanNamesForTypeIncludingAncestors(BeanFactoryUtils.java:187)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1066)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1006)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:904)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:527)
	... 65 more
Caused by: java.lang.ClassNotFoundException: org.quartz.impl.JobDetailImpl
	at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1305)
	at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1157)
	... 84 more
2015-08-17 17:38:11,938 ERROR (org.springframework.web.servlet.DispatcherServlet:497) - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'callRecordController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.manyi.iw.agent.saleapp.service.CallRecordService com.manyi.iw.agent.saleapp.controller.call.CallRecordController.callRecordService; nested exception is java.lang.NoClassDefFoundError: org/quartz/impl/JobDetailImpl
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1204)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:538)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:229)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:725)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
	at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:663)
	at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:629)
	at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:677)
	at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:548)
	at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:489)
	at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)
	at javax.servlet.GenericServlet.init(GenericServlet.java:158)
	at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1231)
	at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1144)
	at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1031)
	at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4914)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5201)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
	at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1648)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)
	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
	at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
	at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:463)
	at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:413)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)
	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
	at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
	at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1487)
	at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:97)
	at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1328)
	at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1420)
	at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:848)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:322)
	at sun.rmi.transport.Transport$1.run(Transport.java:177)
	at sun.rmi.transport.Transport$1.run(Transport.java:174)
	at java.security.AccessController.doPrivileged(Native Method)
	at sun.rmi.transport.Transport.serviceCall(Transport.java:173)
	at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:556)
	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:811)
	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:670)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.manyi.iw.agent.saleapp.service.CallRecordService com.manyi.iw.agent.saleapp.controller.call.CallRecordController.callRecordService; nested exception is java.lang.NoClassDefFoundError: org/quartz/impl/JobDetailImpl
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:555)
	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
	... 63 more
Caused by: java.lang.NoClassDefFoundError: org/quartz/impl/JobDetailImpl
	at java.lang.Class.getDeclaredMethods0(Native Method)
	at java.lang.Class.privateGetDeclaredMethods(Class.java:2570)
	at java.lang.Class.getDeclaredMethods(Class.java:1855)
	at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:571)
	at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:490)
	at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:474)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:241)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineConstructorsFromBeanPostProcessors(AbstractAutowireCapableBeanFactory.java:1059)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1032)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getSingletonFactoryBeanForTypeCheck(AbstractAutowireCapableBeanFactory.java:861)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryBean(AbstractAutowireCapableBeanFactory.java:791)
	at org.springframework.beans.factory.support.AbstractBeanFactory.isTypeMatch(AbstractBeanFactory.java:541)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:406)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:381)
	at org.springframework.beans.factory.BeanFactoryUtils.beanNamesForTypeIncludingAncestors(BeanFactoryUtils.java:187)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1066)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1006)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:904)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:527)
	... 65 more
Caused by: java.lang.ClassNotFoundException: org.quartz.impl.JobDetailImpl
	at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1305)
	at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1157)
	... 84 more
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:mvc="http://www.springframework.org/schema/mvc"
	xmlns:widget="http://www.opensourceforce.org/schema/widget"
	xmlns:task="http://www.springframework.org/schema/task"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:aop="http://www.springframework.org/schema/aop"
	xmlns:tx="http://www.springframework.org/schema/tx"
	xmlns:jdbc="http://www.springframework.org/schema/jdbc"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:jee="http://www.springframework.org/schema/jee"
	xmlns:util="http://www.springframework.org/schema/util"
	xmlns:websocket="http://www.springframework.org/schema/websocket"
	xmlns:lang="http://www.springfspringframeworkramework.org/schema/lang"
	xmlns:oxm="http://www..org/schema/oxm"
	xmlns:p="http://www.springframework.org/schema/p"
	xsi:schemaLocation="
	http://www.springframework.org/schema/mvc
	http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
	http://www.opensourceforce.org/schema/widget
	http://www.opensourceforce.org/schema/widget/spring-widget-0.2.0.xsd
	http://www.springframework.org/schema/task
	http://www.springframework.org/schema/task/spring-task-4.0.xsd
	http://www.springframework.org/schema/context
	http://www.springframework.org/schema/context/spring-context-4.0.xsd
	http://www.springframework.org/schema/beans
	http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
	http://www.springframework.org/schema/jdbc
	http://www.springframework.org/schema/jdbc/spring-jdbc-4.0.xsd
	http://www.springframework.org/schema/tx
	http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
	http://www.springframework.org/schema/aop
	http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
	http://www.springframework.org/schema/jee
	http://www.springframework.org/schema/jee/spring-jee-4.0.xsd
	http://www.springframework.org/schema/util
	http://www.springframework.org/schema/util/spring-util-4.0.xsd
	http://www.springframework.org/schema/websocket
	http://www.springframework.org/schema/websocket/spring-websocket-4.0.xsd
	http://www.springframework.org/schema/lang
	http://www.springframework.org/schema/lang/spring-lang-4.0.xsd
	http://www.springframework.org/schema/oxm
	http://www.springframework.org/schema/oxm/spring-oxm-4.0.xsd">

	<!-- 任务定义 -->
	<!-- 定时调度发布房源审核 ===============================================================-->
	<bean id="housePublishAuditTask" class="com.manyi.iw.agent.saleapp.task.HousePublishAuditTask" />


	<!-- 执行任务 -->
	<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean" autowire="no">
		<property name="triggers">
			<list>
				<ref bean="housePublishAuditTask_Trigger"/>
				<ref bean="followTaskAssign_Trigger"/>
				<ref bean="followTaskStatusUpdate_Trigger"/>
			</list>
		</property>
	</bean>

	<!--=============================定时调度发布房源审核 ======================================-->
	<bean id="housePublishAuditTask_Job" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
		<property name="targetObject" ref="housePublishAuditTask" />
		<property name="targetMethod" value="updateSaleHouseTask" />
		<property name="concurrent" value="false" />
	</bean>
	<bean id="housePublishAuditTask_Trigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
		<property name="jobDetail" ref="housePublishAuditTask_Job" />
		<!--  10分钟执行一次 -->
		<property name="cronExpression">
			<value> 0 0/10 * * * ?</value>
			<!--<value>0,10,20,30,40,50 * * * * ?"</value>-->
		</property>
	</bean>



	<!--=============================定时调度房源维护分配 ======================================-->

	<bean id="followTaskAssign_job" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
		<property name="targetObject" ref="housePublishAuditTask" />
		<property name="targetMethod" value="followTaskAssign" />
		<property name="concurrent" value="false" />
	</bean>
	<bean id="followTaskAssign_Trigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
		<property name="jobDetail" ref="followTaskAssign_job" />
		<!--  每天1点执行一次 -->
		<property name="cronExpression">
			<value>0 0 1 * * ? *</value>
			<!--<value>0,10,20,30,40,50 * * * * ?"</value>-->
		</property>
	</bean>

	<!--=============================定时调度房源维护任务状态更新 ======================================-->
	<bean id="followTaskStatusUpdate_job" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
		<property name="targetObject" ref="housePublishAuditTask" />
		<property name="targetMethod" value="followTaskStatusUpdate" />
		<property name="concurrent" value="false" />
	</bean>
	<bean id="followTaskStatusUpdate_Trigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
		<property name="jobDetail" ref="followTaskStatusUpdate_job" />
		<!--  每天0点执行一次 -->
		<property name="cronExpression">
			<value>0 0 0 * * ? *</value>
			<!--<value>0,10,20,30,40,50 * * * * ?"</value>-->
		</property>
	</bean>
</beans>

  

public class HousePublishAuditTask {
    private Logger logger = Logger.getLogger(getClass());
    @Autowired
    private AgentSaleSOAProxy proxy;
    public void  updateSaleHouseTask(){
        logger.info("job updateSaleHouseTask begin....############################################################## begin date="+new Date().toString());
        proxy.updateSaleHouseTaskToFail();
        logger.info("job updateSaleHouseTask end....##############################################################");
    }
}

 

 

版本不同,配置也是不同的

 

或者

  <properties>  
        <springframework.version>4.0.6.RELEASE</springframework.version>  
        <quartz.version>2.2.1</quartz.version>  
    </properties>

 

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
    xsi:schemaLocation="http://www.springframework.org/schema/beans  
     http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
    <!-- 启动触发器的配置开始 -->
    <bean name="startQuertz" lazy-init="false" autowire="no"
        class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
        <property name="triggers">
            <list>
                <ref bean="myJobTrigger" />
            </list>
        </property>
    </bean>
    <!-- 启动触发器的配置结束 -->
 
    <!-- quartz-2.x的配置 -->
    <bean id="myJobTrigger"
        class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
        <property name="jobDetail">
            <ref bean="myJobDetail" />
        </property>
        <property name="cronExpression">
            <!--middle night 24. do it  -->
            <value>0 0 0 * * ?</value>
        </property>
    </bean>
    <!-- 调度的配置结束 -->
 
    <!-- job的配置开始 -->
    <bean id="myJobDetail"
        class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
        <property name="targetObject">
            <ref bean="myJob" />
        </property>
        <property name="targetMethod">
            <value>work</value>
        </property>
    </bean>
    <!-- job的配置结束 -->
 
    <!-- 工作的bean -->
    <bean id="myJob" class=" com.heli.job.MyJob" />
</beans>

 

 

分享到:
评论

相关推荐

    spring+quartz定时小例子

    Spring 和 Quartz 是两个在 Java 开发中非常重要的框架,它们分别用于依赖注入和任务调度。Spring 是一个全方位的 Java 应用开发框架,提供了一系列强大的功能,如 AOP(面向切面编程)、DI(依赖注入)、事务管理等...

    定时框架spring+quartz

    "定时框架spring+quartz"的结合,就是将Quartz的定时功能与Spring的强大集成能力完美融合,为开发者提供了一种高效、灵活的定时任务解决方案。 Spring框架提供了多种方式来管理定时任务,包括使用Spring的`@...

    spring+quartz+maven项目实例

    【标题】"Spring+Quartz+Maven项目实例"是一个基于Spring框架集成Quartz作业调度库的实战项目,采用Maven作为构建工具。这个实例旨在展示如何在Java应用程序中实现定时任务,支持两种运行模式,既可以直接以独立的...

    Spring+Quartz 集群

    在IT行业中,Spring框架是Java企业级应用开发的首选,而Quartz则是一个强大的任务调度库,常用于实现定时任务。本篇文章将深入探讨如何在Spring环境中集成Quartz以构建一个高可用的集群。 首先,我们需要理解Spring...

    Spring + Quartz配置实例(转载)

    标题 "Spring + Quartz配置实例(转载)" 暗示了我们将讨论如何在Java环境中整合Spring框架与Quartz作业调度库的使用。Quartz是一个开源的作业调度库,它允许开发者安排任务以在特定时间执行,而Spring框架则是一个...

    spring+quartz demo

    【Spring + Quartz 框架整合详解】 Spring 和 Quartz 是两个在 Java 开发领域中非常重要的框架。Spring 是一个全面的、开源的应用框架,提供依赖注入(DI)、面向切面编程(AOP)以及用于简化企业级应用开发的其他...

    Spring+Quartz example

    Spring 和 Quartz 是两个在 Java 开发中非常重要的框架。Spring 是一个全面的后端开发框架,提供了依赖注入、AOP(面向切面编程)、MVC(模型-视图-控制器)等众多功能,极大地简化了Java应用的构建。而Quartz则是一...

    spring+mybatis+quartz任务调度实例和spring+quartz任务调度实例

    里面包含了两个工程项目: 1.Java project工程(含jar包,JDK1.6)。 是spring+quartz的任务调度实例。 2.Java web工程(含jar包,JDK1.7)。 spring+mybatis+quartz任务调度实例

    spring + quartz 集群配置

    java + quartz实现定时任务,实现集群配置,在集群环境下多节点运行定时Quartz定任务,就会存在重复处理任务的现象,为解决这一问题,下面我将介绍使用 Quartz 的 TASK ( 12 张表)实例化到数据库,基于数据库自动...

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

    在IT行业中,构建高效、可扩展的Web应用是至关重要的,而"spring+springMVC+mybatis+quartz动态定时任务创建"就是一个常见的技术栈,用于实现这样的目标。这个组合充分利用了各组件的优势,提供了强大的后端服务支持...

    spring+quartz定时集群支持

    总结起来,"Spring+Quartz定时集群支持"涉及到的知识点主要包括:Spring与Quartz的集成、Quartz的集群配置、`MethodInvokingJobDetailFactoryBean`的使用、数据库表的设计以及通过IHS等手段实现的任务调度。...

    Spring+Quartz定时任务学习文档+实例+jar包

    Spring和Quartz是Java开发中常用的两个框架,它们在企业级应用中被广泛用于实现定时任务的管理和执行。Spring提供了一个轻量级的容器来管理Bean,而Quartz则是一个强大的作业调度库,能够帮助开发者定义和执行定时...

    Spring+quartz相关jar包.rar

    Spring 和 Quartz 是两个在 Java 开发中非常重要的框架,它们分别用于不同的领域。Spring 是一个全面的、开源的应用程序框架,主要用于简化企业级Java应用的开发。Quartz 则是一个强大的、开放源代码的作业调度框架...

    Spring+Quartz定时调度

    **Spring+Quartz定时调度详解** 在Java世界中,实现定时任务调度是非常常见的需求,Spring框架结合Quartz库提供了一种高效且灵活的解决方案。本文将深入探讨Spring与Quartz的整合,以及如何利用它们来创建和管理...

    spring+quartz 动态任务方案

    ### Spring + Quartz 动态任务方案详解 #### 一、Spring与Quartz简介及整合背景 Spring 是一款轻量级的 Java 开发框架,旨在简化企业级应用开发过程中的复杂性,提供了一套完整的解决方案,包括但不限于依赖注入、...

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

    在Spring中整合Quartz,我们可以利用Spring的管理能力,如bean的生命周期管理和事务管理,来更方便地创建和管理定时任务。 **Spring+Quartz动态定时任务创建** 将Spring与Quartz结合,我们可以方便地在运行时动态...

    Spring任务调度配置及说明(spring+quartz)

    《Spring任务调度配置详解:Spring+Quartz的整合应用》 在Java开发中,任务调度是不可或缺的一部分,Spring框架提供了与Quartz集成的能力,使得我们可以方便地管理和执行定时任务。本文将详细介绍如何通过Spring和...

    Spring+Quartz集群部署案例

    最近项目中使用了spring+Quartz定时任务、但是项目最近要集群部署、多个APP下如何利用Quartz 协调处理任务。 大家可以思考一下、现在有 A、B、C三个应用同时作为集群服务器对外统一提供服务、每个应用下各有一个...

    Spring+Quartz 从数据库中获取定时任务和定时时间,动态实现对定时任务的增删改查

    1. **Spring与Quartz的集成**:Spring提供了与Quartz的无缝集成,通过`Spring-Job`和`Spring-Trigger`接口,我们可以将Quartz的作业和触发器与Spring的Bean管理相结合。这样,我们可以在Spring的配置文件中声明作业...

    spring+quartz需要的4个jar包 不需要6个

    在Java开发领域,Spring框架和Quartz库是两个非常重要的组件。Spring是一个全面的企业级应用框架,它提供了依赖注入、AOP(面向切面编程)、MVC(模型-视图-控制器)等特性,帮助开发者构建高效、灵活的Java应用程序...

Global site tag (gtag.js) - Google Analytics