`
moogle
  • 浏览: 109036 次
  • 性别: Icon_minigender_1
社区版块
存档分类
最新评论

疑问:Spring配置Quartz例子出错,请看下.谢谢

    博客分类:
  • Java
阅读更多
研究了一天,在官方论坛也查询了很多,就是锁定不了原因。请各位朋友帮忙看看
spring的配置如下:
    <bean id="emailJobBean" class="org.springframework.scheduling.quartz.JobDetailBean">
    	<property name="jobClass" value="EmailJobBean"/>
    </bean>
	<bean id="simpleTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerBean">
	    <property name="jobDetail" ref="emailJobBean" />
	    <property name="startDelay" value="2000" />
	    <property name="repeatInterval" value="60000" />
	</bean>
	<bean name="quartzScheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
        <property name="triggers">
           <list>
           		<ref bean="simpleTrigger"/>
            </list>
        </property>
    </bean>  

其中被调度的bean
public class EmailJobBean extends QuartzJobBean {

	protected void executeInternal(JobExecutionContext arg0)
			throws JobExecutionException {
		System.out.println("Quartz !!!");
	}

}


启动后就保错
14:29:38,11882 ERROR  [org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:205)] Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'quartzScheduler' defined in ServletContext resource [/WEB-INF/classes/spring-quartz.xml]: Invocation of init method failed; nested exception is org.quartz.SchedulerConfigException: Failure occured during job recovery. [See nested exception: org.quartz.impl.jdbcjobstore.LockException: Failure obtaining db row lock: ORA-00942: table or view does not exist

不知道有没有朋友遇到过类似问题?请大家指点
环境我用的是resin2.1.16,jdk1.4.2,spring2.0.1,quartz1.6.0
分享到:
评论
15 楼 eyejava 2007-03-08  
dwangel 写道
另外可能是自动装配惹得祸,存在dataSource这个bean就自动用数据库的状态维持了。

dwangel 写道
foxty 写道
因为这个时候你的quartz是jobstore用的HDBCJobStore模式,此时会从数据库查询任务。

你如果只是测试的话,可以在你的classpath下加一个文件quartz.properties,并且加上一句org.quartz.jobStore.class = org.quartz.simpl.RAMJobStore 。就会采取内存存储的模式了。

或者可以直接在spring配置中做:

<bean name="quartzScheduler"
class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="simpleTrigger" />
</list>
</property>
<property name="quartzProperties">
<props>
<prop key="org.quartz.jobStore.class">
org.quartz.simpl.RAMJobStore
</prop>
</props>
</property>
</bean>

autowire真是一个万恶的家伙, 这个问题整了我一个下午,怒了.
设置org.quartz.jobStore.class为org.quartz.simpl.RAMJobStore也是没有用的.
因为
if (this.dataSource != null) {
				mergedProps.put(StdSchedulerFactory.PROP_JOB_STORE_CLASS, LocalDataSourceJobStore.class.getName());
			}

SchedulerFactoryBean的setDataSource(DataSource)方法javadoc说:
Set the default DataSource to be used by the Scheduler. If set, this will override corresponding settings in Quartz properties.

Note: If this is set, the Quartz settings should not define a job store "dataSource" to avoid meaningless double configuration.

A Spring-specific subclass of Quartz' JobStoreCMT will be used. It is therefore strongly recommended to perform all operations on the Scheduler within Spring-managed (or plain JTA) transactions. Else, database locking will not properly work and might even break (e.g. if trying to obtain a lock on Oracle without a transaction).

Supports both transactional and non-transactional DataSource access. With a non-XA DataSource and local Spring transactions, a single DataSource argument is sufficient. In case of an XA DataSource and global JTA transactions, SchedulerFactoryBean's "nonTransactionalDataSource" property should be set, passing in a non-XA DataSource that will not participate in global transactions.

See Also:
setNonTransactionalDataSource
setQuartzProperties
setTransactionManager
LocalDataSourceJobStore
14 楼 dwangel 2006-12-18  
foxty 写道
因为这个时候你的quartz是jobstore用的HDBCJobStore模式,此时会从数据库查询任务。

你如果只是测试的话,可以在你的classpath下加一个文件quartz.properties,并且加上一句org.quartz.jobStore.class = org.quartz.simpl.RAMJobStore 。就会采取内存存储的模式了。

或者可以直接在spring配置中做:

<bean name="quartzScheduler"
class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="simpleTrigger" />
</list>
</property>
<property name="quartzProperties">
<props>
<prop key="org.quartz.jobStore.class">
org.quartz.simpl.RAMJobStore
</prop>
</props>
</property>
</bean>
13 楼 dwangel 2006-12-18  
按照错误信息显示,你使用的quartz应该是使用数据进行job的状态的维护的,但是在数据库中没有找到相应的table,从而无法正常建立scheduler 。

如果你的不需要错误重启功能,改成用内存维护就好。

另外可能是自动装配惹得祸,存在dataSource这个bean就自动用数据库的状态维持了。
12 楼 foxty 2006-12-18  
因为这个时候你的quartz是jobstore用的HDBCJobStore模式,此时会从数据库查询任务。

你如果只是测试的话,可以在你的classpath下加一个文件quartz.properties,并且加上一句org.quartz.jobStore.class = org.quartz.simpl.RAMJobStore 。就会采取内存存储的模式了。
11 楼 抛出异常的爱 2006-12-18  
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<!--起动Bean-->
 <bean id="z" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
 	<property name="triggers">
 		<list>
 	
			<ref bean="cronReportTrigger"/>
 		</list>
 	</property>
 </bean> 
<!--实际的工作Bean-->
  <bean id="courseService" class="com.spring.helloworld.CourseService"></bean>
<!--jobBean用于设定启动时运用的Bean与方法-->
 <bean id="scheduledReportJobDetail"  
class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
	 <property name="targetObject">
	 	<ref  bean="courseService"/>	
	 </property>
	 <property name="targetMethod">
		 <value>sendCourseEnrollmentReport</value>
	 </property>
 </bean>
<!--定时器设定起动频率&启动时间我设的是每5秒起动一次 (0 0 0 4 * * ?每日四点起动....)-->
 <bean id="cronReportTrigger" 
class="org.springframework.scheduling.quartz.CronTriggerBean">
 <property  name="jobDetail"><ref bean="scheduledReportJobDetail"/>
 </property>
 <property name="cronExpression"><value>10,15,20,25,30,35,40,45,50,55 * * * * ?</value>  
</property>
 </bean>
 	
</beans>

看了你的问题周日自己试着作了一次....

引用
14:29:38,11882 ERROR  [org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:205)] Context initialization failed  
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'quartzScheduler' defined in ServletContext resource [/WEB-INF/classes/spring-quartz.xml]: Invocation of init method failed; nested exception is org.quartz.SchedulerConfigException: Failure occured during job recovery. [See nested exception: org.quartz.impl.jdbcjobstore.LockException: Failure obtaining db row lock: ORA-00942: table or view does not exist  

从没出过这种错.....
看来好像是你又以什么方式去调用数据库之后产生的问题
PS:你的EmailJobBean生明方式不对应该以小写开头,并用Bean标签声明...
10 楼 抛出异常的爱 2006-12-14  
init method failed?是否是你的Quartz实现的接口不对?
jobDataAsMap这个接口没看到配?
有没有关系?
9 楼 moogle 2006-12-14  
现在就是我的hibernate和quartz的配置不能并存 ,
这2者之间不会有啥不兼容吧。。。
8 楼 moogle 2006-12-13  
ddandyy 写道
很奇怪
   <bean id="emailJobBean" class="org.springframework.scheduling.quartz.JobDetailBean"> 
    <property name="jobClass" value="EmailJobBean"/> 
   </bean> 

你没定义 id=EmailJobBean   为什么这句不报错呢


赫赫 ,这个地方就是那个jobClass的值 就是一个类的完整名称,
我这个类没有包名,所以直接就是这么写的。
7 楼 moogle 2006-12-13  
<br/>
<strong>binker 写道:</strong><br/>
<div class='quote_div'>
<p>可疑之处: 1你的EmailJobBean有包前缀么? 若有那应该定义成<span> </span><span class='tag'>&lt;</span><span class='tag-name'>property</span><span> </span><span class='attribute'>name</span><span>=</span><span class='attribute-value'>"jobClass"</span><span> </span><span class='attribute'>value</span><span>=</span><span class='attribute-value'>"com.yourpackagename.EmailJobBean"</span><span class='tag'>/&gt;</span><span>  </span></p>
<p>  <span class='tag'>&lt;</span><span class='tag-name'>bean</span><span> </span><span class='attribute'>id</span><span>=</span><span class='attribute-value'>"emailJobBean"</span><span> </span><span class='attribute'>class</span><span>=</span><span class='attribute-value'>"org.springframework.scheduling.quartz.JobDetailBean"</span><span class='tag'>&gt;</span><span>  </span> </p>
<li class=''><span>    </span><span class='tag'>&lt;</span><span class='tag-name'>property</span><span> </span><span class='attribute'>name</span><span>=</span><span class='attribute-value'>"jobClass"</span><span> </span><span class='attribute'>value</span><span>=</span><span class='attribute-value'>"EmailJobBean"</span><span class='tag'>/&gt;</span><span>  </span> </li>
<li class='alt'><span>   </span><span class='tag'><span class='tag-name'>bean</span><span class='tag'>&gt;</span><span>  </span> </span></li>
<li class='alt'><span></span>
<p>启动后就保错 <br/>
</p>
<div class='code_title'>代码</div>
<div class='code_div'>
<div class='dp-highlighter'>
<div class='bar'>
<ol class='dp-j'>
    <li class='alt'><span><span class='number'>14</span><span>:</span><span class='number'>29</span><span>:</span><span class='number'>38</span><span>,</span><span class='number'>11882</span><span> ERROR  [org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:</span><span class='number'>205</span><span>)] Context initialization failed   </span></span> </li>
    <li class=''><span>org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'quartzScheduler' defined in ServletContext resource [/WEB-INF/classes/spring-quartz.xml]: Invocation of init method failed; nested exception is org.quartz.SchedulerConfigException: Failure occured during job recovery. [See nested exception: org.quartz.impl.jdbcjobstore.LockException: Failure obtaining db row lock: ORA-</span><span class='number'>00942</span><span>: table or view does not exist   </span> </li>
</ol>
</div>
</div>
<p> </p>
<p>可疑之处2:你的spring-quartz.xml 文件配置,注意到在错误堆栈的最后一行提示jdbcstore lock exception, table or view does not exist.是否其中配置了数据源信息.你可以尝试把其他所有的配置都注释掉,只保留quartz job bean的定义.然后再调试.</p>
</div></li>
</div>
<p>谢谢先</p>
<p>1.我只是做个测试,本身就没有加包。 如果在配置文件写错这些,eclipse会直接提示类不存在的,强行跑也会ClassNotFound</p>
<p>2.我将hibernate配置的文件去掉。 Quartz可正常跑,去掉quartz,hibernate可以正常加载应用<br/>
  加在一起后就还是出现同样的错误。</p>
<p>下面补spring-hibernate.xml 配置<br/>
----------------------------------------------------------------------</p>
<div class='dp-highlighter'>
<div class='bar'>
<ol class='dp-xml'>
    <li class='alt'><span><span class='tag'>&lt;</span><span class='tag-name'>bean</span><span> </span><span class='attribute'>id</span><span>=</span><span class='attribute-value'>"dataSource"</span><span> </span><span class='attribute'>class</span><span>=</span><span class='attribute-value'>"org.springframework.jndi.JndiObjectFactoryBean"</span><span class='tag'>&gt;</span><span>  </span></span> </li>
    <li class=''><span>    </span><span class='tag'>&lt;</span><span class='tag-name'>property</span><span> </span><span class='attribute'>name</span><span>=</span><span class='attribute-value'>"jndiName"</span><span> </span><span class='attribute'>value</span><span>=</span><span class='attribute-value'>"${jdbc.jndiName}"</span><span> </span><span class='tag'>/&gt;</span><span>  </span> </li>
    <li class='alt'><span><span class='tag'><span class='tag-name'>bean</span><span class='tag'>&gt;</span><span>  </span> </span></span></li>
    <li class=''><span>  </span> </li>
    <li class='alt'><span><span class='tag'>&lt;</span><span class='tag-name'>bean</span><span> </span><span class='attribute'>id</span><span>=</span><span class='attribute-value'>"hibernateTemplate"</span><span> </span><span class='attribute'>class</span><span>=</span><span class='attribute-value'>"org.springframework.orm.hibernate3.HibernateTemplate"</span><span> </span><span class='attribute'>autowire</span><span>=</span><span class='attribute-value'>"byName"</span><span class='tag'>/&gt;</span><span>  </span> </span></li>
    <li class=''><span><span class='tag'>&lt;</span><span class='tag-name'>bean</span><span> </span><span class='attribute'>id</span><span>=</span><span class='attribute-value'>"sessionFactory"</span><span> </span><span class='attribute'>class</span><span>=</span><span class='attribute-value'>"org.springframework.orm.hibernate3.LocalSessionFactoryBean"</span><span class='tag'>&gt;</span><span>  </span> </span></li>
    <li class='alt'><span>    </span><span class='tag'>&lt;</span><span class='tag-name'>property</span><span> </span><span class='attribute'>name</span><span>=</span><span class='attribute-value'>"dataSource"</span><span> </span><span class='attribute'>ref</span><span>=</span><span class='attribute-value'>"dataSource"</span><span> </span><span class='tag'>/&gt;</span><span>  </span> </li>
    <li class=''><span>    </span><span class='tag'>&lt;</span><span class='tag-name'>property</span><span> </span><span class='attribute'>name</span><span>=</span><span class='attribute-value'>"mappingDirectoryLocations"</span><span class='tag'>&gt;</span><span>  </span> </li>
    <li class='alt'><span>        </span><span class='tag'>&lt;</span><span class='tag-name'>list</span><span class='tag'>&gt;</span><span>  </span> </li>
    <li class=''><span>        </span><span class='tag'>&lt;</span><span class='tag-name'>value</span><span class='tag'>&gt;</span><span>classpath:org/moo/pojo/</span><span class='tag'><span class='tag-name'>value</span><span class='tag'>&gt;</span><span>  </span> </span></li>
    <li class='alt'><span>        </span><span class='tag'><span class='tag-name'>list</span><span class='tag'>&gt;</span><span>  </span> </span></li>
    <li class=''><span>    </span><span class='tag'><span class='tag-name'>property</span><span class='tag'>&gt;</span><span>  </span> </span></li>
    <li class='alt'><span>    </span><span class='tag'>&lt;</span><span class='tag-name'>property</span><span> </span><span class='attribute'>name</span><span>=</span><span class='attribute-value'>"hibernateProperties"</span><span class='tag'>&gt;</span><span>  </span> </li>
    <li class=''><span>        </span><span class='tag'>&lt;</span><span class='tag-name'>props</span><span class='tag'>&gt;</span><span>  </span> </li>
    <li class='alt'><span>            </span><span class='tag'>&lt;</span><span class='tag-name'>prop</span><span> </span><span class='attribute'>key</span><span>=</span><span class='attribute-value'>"hibernate.dialect"</span><span class='tag'>&gt;</span><span>${hibernate.dialect}</span><span class='tag'><span class='tag-name'>prop</span><span class='tag'>&gt;</span><span>  </span> </span></li>
    <li class=''><span>            </span><span class='tag'>&lt;</span><span class='tag-name'>prop</span><span> </span><span class='attribute'>key</span><span>=</span><span class='attribute-value'>"hibernate.show_sql"</span><span class='tag'>&gt;</span><span>${hibernate.show_sql}</span><span class='tag'><span class='tag-name'>prop</span><span class='tag'>&gt;</span><span>  </span> </span></li>
    <li class='alt'><span>        </span><span class='tag'><span class='tag-name'>props</span><span class='tag'>&gt;</span><span>  </span> </span></li>
    <li class=''><span>    </span><span class='tag'><span class='tag-name'>property</span><span class='tag'>&gt;</span><span>  </span> </span></li>
    <li class='alt'><span><span class='tag'><span class='tag-name'>bean</span><span class='tag'>&gt;</span><span>  </span> </span></span></li>
    <li class=''><span> //下面都是类似的dao,service比较多就不一一列出来了   </span> </li>
    <li class='alt'><span> </span><span class='tag'>&lt;</span><span class='tag-name'>bean</span><span> </span><span class='attribute'>id</span><span>=</span><span class='attribute-value'>"codeService"</span><span> </span><span class='attribute'>class</span><span>=</span><span class='attribute-value'>"org.moo.service.CodeService"</span><span> </span><span class='attribute'>autowire</span><span>=</span><span class='attribute-value'>"byName"</span><span class='tag'>/&gt;</span><span>  </span> </li>
    <li class=''><span> </span><span class='tag'>&lt;</span><span class='tag-name'>bean</span><span> </span><span class='attribute'>id</span><span>=</span><span class='attribute-value'>"codeDao"</span><span> </span><span class='attribute'>class</span><span>=</span><span class='attribute-value'>"org.moo.dao.CodeDao"</span><span> </span><span class='attribute'>autowire</span><span>=</span><span class='attribute-value'>"byName"</span><span class='tag'>/&gt;</span><span>  </span> </li>
</ol>
</div>
<p><br/>
另我看日志输入在出现错误前有:</p>
<div class='dp-highlighter'>
<ol class='dp-xml'>
    <li class='alt'><span><span>15:43:50,23182 INFO   [org.quartz.core.QuartzScheduler.(QuartzScheduler.java:209)] Quartz Scheduler v.null.null.null created.   </span></span> </li>
    <li class=''><span>15:43:50,23241 INFO   [org.quartz.impl.jdbcjobstore.JobStoreSupport.initialize(JobStoreSupport.java:542)] Using db table-based data access locking (synchronization).   </span> </li>
    <li class='alt'><span>15:43:50,23390 DEBUG  [org.quartz.impl.jdbcjobstore.DBSemaphore.obtainLock(DBSemaphore.java:106)] Lock 'TRIGGER_ACCESS' is desired by: main   </span> </li>
    <li class=''><span>15:43:50,24023 DEBUG  [org.quartz.impl.jdbcjobstore.StdRowLockSemaphore.executeSQL(StdRowLockSemaphore.java:88)] Lock 'TRIGGER_ACCESS' is being obtained: main   </span> </li>
    <li class='alt'><span>15:43:51,24291 DEBUG  [org.quartz.impl.jdbcjobstore.StdRowLockSemaphore.executeSQL(StdRowLockSemaphore.java:107)] Lock 'TRIGGER_ACCESS' was not obtained by: main   </span> </li>
    <li class=''><span>15:43:51,24332 DEBUG  [org.quartz.utils.ExceptionHelper.supportsNestedThrowable(ExceptionHelper.java:97)] Detected JDK support for nested exceptions.   </span> </li>
    <li class='alt'><span>15:43:51,24427 INFO   [org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:272)] Destroying singletons in {org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans   </span> </li>
    <li class=''><span>15:43:51,24438 INFO   [org.springframework.orm.hibernate3.AbstractSessionFactoryBean.destroy(AbstractSessionFactoryBean.java:185)] Closing Hibernate SessionFactory  </span> </li>
</ol>
</div>
<p><br/>
然后才出现了最先提到的错误</p></div>
6 楼 ddandyy 2006-12-13  
很奇怪
   <bean id="emailJobBean" class="org.springframework.scheduling.quartz.JobDetailBean"> 
    <property name="jobClass" value="EmailJobBean"/> 
   </bean> 

你没定义 id=EmailJobBean   为什么这句不报错呢
5 楼 moogle 2006-12-13  
...
我只给出了和quartz相关的,其他的就还有一个hibernate的配置
然后就没有了。
去掉quartz的都很正常的跑。这个quartz跑得和hibernate一点关系都没有

总共分了3个配置
spring.xml
----------------------
<beans default-autowire="byName">
	<!-- 加载全局配置文件 -->
	<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
		<property name="locations">
			<list>
				<value>classpath:/mail.properties</value>
				<value>classpath:/jdbc.properties</value>
				<value>classpath:/hibernate.properties</value>
			</list>
		</property>
	</bean>
</beans>

spring-hibernate.xml就是配置了数据源和dao,service
spring-quartz.xml就是一楼的那些内容
4 楼 binker 2006-12-13  
<p>可疑之处: 1你的EmailJobBean有包前缀么? 若有那应该定义成<span> </span><span class='tag'>&lt;</span><span class='tag-name'>property</span><span> </span><span class='attribute'>name</span><span>=</span><span class='attribute-value'>"jobClass"</span><span> </span><span class='attribute'>value</span><span>=</span><span class='attribute-value'>"com.yourpackagename.EmailJobBean"</span><span class='tag'>/&gt;</span><span>  </span></p>
<p>  <span class='tag'>&lt;</span><span class='tag-name'>bean</span><span> </span><span class='attribute'>id</span><span>=</span><span class='attribute-value'>"emailJobBean"</span><span> </span><span class='attribute'>class</span><span>=</span><span class='attribute-value'>"org.springframework.scheduling.quartz.JobDetailBean"</span><span class='tag'>&gt;</span><span>  </span> </p>
<li class=''><span>    </span><span class='tag'>&lt;</span><span class='tag-name'>property</span><span> </span><span class='attribute'>name</span><span>=</span><span class='attribute-value'>"jobClass"</span><span> </span><span class='attribute'>value</span><span>=</span><span class='attribute-value'>"EmailJobBean"</span><span class='tag'>/&gt;</span><span>  </span></li>
<li class='alt'><span>   </span><span class='tag'>&lt;/</span><span class='tag-name'>bean</span><span class='tag'>&gt;</span><span>  </span></li>
<li class='alt'><span></span></li>
<p>启动后就保错 <br/>
</p>
<div class='code_title'>代码</div>
<div class='code_div'>
<div class='dp-highlighter'>
<div class='bar'>
<ol class='dp-j'>
    <li class='alt'><span><span class='number'>14</span><span>:</span><span class='number'>29</span><span>:</span><span class='number'>38</span><span>,</span><span class='number'>11882</span><span> ERROR  [org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:</span><span class='number'>205</span><span>)] Context initialization failed   </span></span></li>
    <li class=''><span>org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'quartzScheduler' defined in ServletContext resource [/WEB-INF/classes/spring-quartz.xml]: Invocation of init method failed; nested exception is org.quartz.SchedulerConfigException: Failure occured during job recovery. [See nested exception: org.quartz.impl.jdbcjobstore.LockException: Failure obtaining db row lock: ORA-</span><span class='number'>00942</span><span>: table or view does not exist   </span></li>
</ol>
</div>
</div>
<p> </p>
<p>可疑之处2:你的spring-quartz.xml 文件配置,注意到在错误堆栈的最后一行提示jdbcstore lock exception, table or view does not exist.是否其中配置了数据源信息.你可以尝试把其他所有的配置都注释掉,只保留quartz job bean的定义.然后再调试.</p></div>
3 楼 ddandyy 2006-12-13  
那就是配置文件有问题

你给出来的不全吧
2 楼 moogle 2006-12-13  
引用
public class EmailJobBean implements StatefulJob


测试后,错误依旧。
@-@.

PS:感谢回帖。
1 楼 ddandyy 2006-12-13  
public class EmailJobBean implements StatefulJob

你试试

相关推荐

    关于spring中quartz的配置

    &lt;bean id="schedulerFactoryBean" class="org.springframework.scheduling.quartz.SchedulerFactoryBean"&gt; &lt;!-- 配置Quartz属性 --&gt; &lt;property name="configLocation" value="classpath:quartz.properties"/&gt; &lt;!...

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

    4. **整合Dubbo和Nacos**:Spring Cloud Alibaba的Nacos可以作为服务发现和配置中心。我们需要在YAML文件中配置Nacos的相关信息,如服务器地址、端口、命名空间等,并将Dubbo的服务注册到Nacos。 ```yaml cloud: ...

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

    本文将深入探讨如何在Spring中配置多个Quartz定时任务,并结合`quartz.properties`文件进行详细讲解。 首先,我们需要理解Quartz的基本概念。Quartz是开源的作业调度框架,允许应用程序在特定时间执行任务。它支持...

    spring+quartz定时小例子

    &lt;bean id="scheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean"&gt; &lt;property name="configLocation" value="classpath:quartz.properties"/&gt; ``` 2. **Quartz 配置**: 通常会...

    Java_Spring与Quartz的整合

    - 通过实现`org.springframework.scheduling.quartz.JobExecutionException`,可以捕获Job执行过程中的异常,进行统一处理。 8. **事务支持** - 如果Job需要在数据库事务中执行,可以利用Spring的事务管理功能,...

    spring quartz简单例子

    你需要创建一个实现了`org.quartz.Job`接口的类,并重写`execute(JobExecutionContext context)`方法,这是任务的实际执行逻辑。 6. **定义Trigger**:Trigger定义了Job何时被执行。Quartz提供了多种Trigger类型,...

    spring+quartz demo

    Spring 和 Quartz 结合,可以使用 Quartz 提供的 Web 监控界面(如 `org.quartz.plugins.management.JobRunShellServlet`)或者通过 API 进行任务监控和管理。 8. **异常处理**: 在 Job 执行过程中如果出现异常...

    spring集成quartz集群配置

    Spring提供了`org.springframework.scheduling.quartz.JobDetailBean`来创建Job,`org.springframework.scheduling.quartz.CronTriggerBean`或`SimpleTriggerBean`来定义触发规则。在Spring配置文件中,我们可以声明...

    quartz和spring-quartz

    Quartz和Spring-Quartz是两个在Java世界中广泛使用的定时任务管理框架。Quartz是一个开源的作业调度框架,允许应用程序定义和调度任务在特定时间执行。而Spring-Quartz则是Spring框架对Quartz的集成,它使得在Spring...

    spring和quartz整合示例

    所需jar如下: spring-beans-3.2.4.RELEASE.jar spring-core-3.2.4.RELEASE.jar spring-expression-3.2.4.RELEASE....quartz-all-2.1.7.jar spring-tx-3.2.4.RELEASE.jar slf4j-log4j12-1.6.1.jar slf4j-api-1.6.1.jar

    spring之quartz例子

    spring之quartz例子,与oracle整合,不过spring中的MethodInvokingJobDetailFactoryBean方法在存数据库时序列化有bug,在本例子中,使用了修复后的MethodInvokingJobDetailFactoryBean方法,避免了因序列化而报错。

    Spring4.X+Quartz2.X

    3. **定义Job**:创建实现`org.springframework.core.task.TaskExecutor`接口的类,或者直接使用`org.springframework.scheduling.quartz.JobDetailBean`,来定义具体的任务逻辑。 4. **配置Trigger**:创建一个...

    Spring+quartz相关jar包.rar

    3. 定义 Job 和 Trigger:创建 Quartz 作业类(Job),实现 org.quartz.Job 接口,并定义触发器(Trigger)来决定何时执行作业。 4. 注册 Job 和 Trigger:在 Spring 配置文件中,通过 `&lt;bean&gt;` 标签注册 Job 和 ...

    spring 配置quartz需要的jar包

    &lt;bean id="scheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean"&gt; &lt;!-- 配置 Quartz 的属性,如 JobStore 类型、线程池大小等 --&gt; ``` 3. **定义Job和Trigger**:创建实现`org....

    spring3配置quartz定时任务

    &lt;bean id="scheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean"&gt; &lt;!-- 这里会填充你的触发器 --&gt; &lt;property name="configLocation" value="classpath:quartz.properties"/&gt; ...

    spring-quartz定时设置详细说明

    quartz.jobStore.type=org.quartz.impl.jdbcjobstore.StdJDBCJobStore quartz.jobStore.dataSource=myDS quartz.dataSource.myDS.driverClass=com.mysql.jdbc.Driver quartz.dataSource.myDS.URL=jdbc:mysql://...

    Spring中的Quartz配置-Spring-定时器-java定时器.doc

    Spring 中的 Quartz 配置-Spring 定时器-java 定时器 在 Spring 框架中,Quartz 是一个非常流行的开源作业调度器,可以实现任务的定时执行。在本篇文章中,我们将讨论如何在 Spring 中配置 Quartz,以实现 Java ...

    Spring -Quartz的配置

    这里,`quartz.properties`是Quartz的配置文件,`jobFactory`是Spring的JobFactory,`myJob`定义了一个Job,`yourService`是你打算在Job中调用的服务,`executeTask`是服务中执行定时任务的方法,`cronTrigger`则是...

    定时器的配置文件(两种方式:springmvc自带定时,Quartz与spring结合的定时)

    本篇文章将详细讲解两种在Spring MVC框架中实现定时任务的方法:Spring MVC自带的定时器以及Quartz与Spring的集成。 首先,我们来看看Spring MVC自带的定时任务。Spring MVC作为Spring框架的一个模块,主要处理HTTP...

    spring+quartz使用jar包

    10. **配置文件**:除了代码配置外,Quartz还可以通过`quartz.properties`配置文件进行设置,如数据库连接信息、线程池大小等。 在实际项目中,结合Spring和Quartz,开发者可以轻松地创建和管理复杂的时间驱动任务...

Global site tag (gtag.js) - Google Analytics