The hole that I stepped on
-
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.
-
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
-
The following provides the configuration that you use
-
Maven Pom.xml
-
<!-- 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>
- Configuration of the
-
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)