quart Spring 配置

来源:互联网 发布:数据库建模关系 编辑:程序博客网 时间:2024/05/01 07:02

quartzWithSpring.rar   

 

配置:quartz.properties

org.quartz.scheduler.instanceName = DefaultQuartzScheduler
org.quartz.scheduler.rmi.export = false
org.quartz.scheduler.rmi.proxy = false
org.quartz.scheduler.wrapJobExecutionInUserTransaction = false

org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount = 10
org.quartz.threadPool.threadPriority = 5
org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread = true

org.quartz.jobStore.misfireThreshold = 60000

#org.quartz.jobStore.class = org.quartz.simpl.RAMJobStore

org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreTX
#org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.HSQLDBDelegate
org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.StdJDBCDelegate
#org.quartz.jobStore.useProperties = true
org.quartz.jobStore.tablePrefix = QRTZ_ 
org.quartz.jobStore.isClustered = false 
org.quartz.jobStore.maxMisfiresToHandleAtATime=1

applicationContext.xml:

<?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:aop="http://www.springframework.org/schema/aop"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:context="http://www.springframework.org/schema/context"
     xmlns:jee="http://www.springframework.org/schema/jee"
    xsi:schemaLocation="
    http://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context-2.5.xsd
    http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-2.5.xsd
    http://www.springframework.org/schema/txhttp://www.springframework.org/schema/tx/spring-tx-2.5.xsd
    http://www.springframework.org/schema/aophttp://www.springframework.org/schema/aop/spring-aop-2.5.xsd
     http://www.springframework.org/schema/jee
       http://www.springframework.org/schema/jee/spring-jee-2.5.xsd"  >
 
   <context:component-scan base-package="com.sundoctor"/>
 
 <!-- 属性文件读入 -->
 <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
  <property name="locations">
   <list>
    <value>classpath:jdbc.properties</value>
   </list>
  </property>
 </bean>
 
 <!-- 数据源定义,使用c3p0 连接池 -->
 <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
 <property name="driverClass" value="${jdbc.driverClassName}" /> 
 <property name="jdbcUrl" value="${jdbc.url}" /> 
 <property name="user" value="${jdbc.username}" /> 
 <property name="password" value="${jdbc.password}" />  
 <property name="initialPoolSize" value="${cpool.minPoolSize}"/> 
 <property name="minPoolSize" value="${cpool.minPoolSize}" /> 
 <property name="maxPoolSize" value="${cpool.maxPoolSize}" /> 
 <property name="acquireIncrement" value="${cpool.acquireIncrement}" />
    <property name="maxIdleTime" value="${cpool.maxIdleTime}"/>  
 </bean>  

</beans>

3:applicationContext-quartz.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">

<beans>
 <bean name="quartzScheduler"
  class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
  <property name="dataSource">
   <ref bean="dataSource" />
  </property>
  <property name="applicationContextSchedulerContextKey" value="applicationContextKey" />
  <property name="configLocation" value="classpath:quartz.properties" />
 </bean>

 <bean id="jobDetail" class="org.springframework.scheduling.quartz.JobDetailBean">
  <property name="jobClass">
   <value>com.sundoctor.example.service.MyQuartzJobBean</value>
  </property>
  <property name="jobDataAsMap">
   <map>
    <entry key="simpleService">
     <ref bean="simpleService" />
    </entry>
   </map>
  </property>
 </bean>

</beans>

 

 

 

 

原创粉丝点击