我正在尝试使用Spring 4.0.1和Quartz 1.5.2创建一个cron作业,但是当我在服务器上运行它时出现错误。错误显示:
SEVERE: Servlet [appServlet] in web application [/SpringRestSample] threw load() exception
java.lang.ClassNotFoundException: org.quartz.impl.JobDetailImpl
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.getDeclaredMethods(Unknown Source)
我的xml配置是:
<beans:bean id="removeExpiredSessionFetchJob" class="org.springframework.scheduling.quartz.JobDetailFactoryBean">
<beans:property name="jobClass">
<beans:value>com.iris.spring.rest.model.RemoveExpiredSessionFetchJob</beans:value>
</beans:property>
</beans:bean>
<beans:bean id="removeExpiredSessionTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
<beans:property name="jobDetail">
<beans:ref bean="removeExpiredSessionFetchJob" />
</beans:property>
<beans:property name="cronExpression">
<!-- <value>0 0/55 * * * ?</value> -->
<beans:value>0 */1 * * * ?</beans:value>
</beans:property>
</beans:bean>
<beans:bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<beans:property name="triggers">
<beans:list>
<beans:ref bean="removeExpiredSessionTrigger" />
</beans:list>
</beans:property>
</beans:bean>
我的pom.xml是:
<properties>
<java-version>1.6</java-version>
<org.springframework-version>4.1.0.RELEASE</org.springframework-version>
<org.aspectj-version>1.7.4</org.aspectj-version>
<org.slf4j-version>1.7.5</org.slf4j-version>
<jackson.databind-version>2.2.3</jackson.databind-version>
</properties>
<dependency>
<groupId>quartz</groupId>
<artifactId>quartz</artifactId>
<version>1.5.2</version>
</dependency>
答案 0 :(得分:8)
quartz
/ quartz
是一些旧的Quartz版本,根据Maven Repository webpage移至org.quartz-scheduler
/ quartz
。因此,包含类JobDetailImpl
的正确Quartz依赖项应该是:
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>2.2.1</version>
</dependency>