Spring+quartz (various version compatibility issues)

Source: Internet
Author: User

The hole that I stepped on

  1. Encounter Crontriggerfactorybean class NotFound

    The reason is that with a version of 3.1 or less, I'm using the 3.06 Discovery Spring-context-support jar file underneath, there's no such class at all, Change to Org.springframework.scheduling.quartz.CronTriggerBean.


  2. Encounter Jobdetail class NotFound

    The reason is to use more than 2.0 versions, because in these versions,Jobdetail is interface, for specific reasons, the author may feel that the abstraction of the class does not have an interface abstract good

  3. The following provides the configuration that you use

    1. Maven Pom.xml

      1.  <!--  Properties  -->  <properties>  <spring-version>3.0.6.release </spring-version>  </properties>  <dependencies>  <!--  spring 3 dependencies --><dependency><groupid>org.springframework</ Groupid><artifactid>spring-core</artifactid><version>${spring-version}</version> </dependency> <!-- QuartzJobBean in spring-context-support.jar -->< dependency><groupid>org.springframework</groupid><artifactid>spring-context-support</ artifactid><version>${spring-version}</version></dependency> <!-- Spring  + quartz need transaction --><dependency><groupid>org.springframework </groupId><artifactId>spring-tx</artifactId><version>${spring-version}</version> </dependency> <!-- quartz framework --><dependency><groupid>org.quartz-scheduler</groupid> <artifactId>quartz</artifactId><version>1.8.6</version></dependency>< dependency><groupid>junit</groupid><artifactid>junit</artifactid><version>4.8 </version><scope>test</scope></dependency>  </dependencies>
      2. Configuration of the
      3. Applicationcontext.xml file

<bean id= "Testjob" class= "Org.alipay.mingdu.quartz.jobs.TestJob" ></bean><bean id= "Testjobdetail" class= "Org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean" ><!--assigning task Classes-->< Property Name= "TargetObject" ref= "testjob"/><!--Specify how the task executes--><property name= "Targetmethod" value= " Execute "/></bean><bean id=" Testjobtrigger "class=" Org.springframework.scheduling.quartz.CronTriggerBean "><property name=" Jobdetail "ref=" Testjobdetail "/> <!--run once every 10 seconds--><property name= "cronexpression" value= "0/10 * * * *?"/></bean><bean class= "org.sp Ringframework.scheduling.quartz.SchedulerFactoryBean "><property name=" triggers "><list><ref Bean= "Testjobtrigger"/></list></property></bean>

Effect:


Spring+quartz (various version compatibility issues)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.