Spring+quartz的任务调度问题

bmj bmj 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我在网上找了些quartz的例子来看了,按照上面写的编写好了配置文件,可是好像有点问题,配置文件如下:
<!-- 要调度的对象 -->
<bean id="day_compute" class="cn.edu.aust.business.Day_auto_compute" />
<bean id="month_compute" class="cn.edu.aust.business.Month_auto_compute" />
<bean id="year_compute" class="cn.edu.aust.business.Year_auto_compute" />


<!-- 由JobDetailBean 负责 -->
<bean id="year_compute_entity" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject">
<ref local="year_compute" />
</property>
<property name="targetMethod">
<value>compute</value>
</property>
</bean>

<bean id="month_compute_entity" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject">
<ref local="month_compute" />
</property>
<property name="targetMethod">
<value>compute</value>
</property>
</bean>

<bean id="day_compute_entity" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject">
<ref local="day_compute" />
</property>
<property name="targetMethod">
<value>compute</value>
</property>
</bean>


<!-- 定义触发的时间 -->
<bean id = "day_cron" class = "org.springframework.scheduling.quartz.CronTriggerBean" >
<property name ="jobDetail" >
<ref bean ="day_compute_entity" />
</property >
<property name ="cronExpression" >
<value > 0 0 2 * * ? </value > <!-- 每天早上2点触发 -->
</property >
</bean >

<bean id = "month_cron" class = "org.springframework.scheduling.quartz.CronTriggerBean" >
<property name ="jobDetail" >
<ref bean ="month_compute_entity" />
</property >
<property name ="cronExpression" >
<value > 0 55 23 L * ? </value > <!-- 每个月最后一天的23点55触发 -->
</property >
</bean >

<bean id = "year_cron" class = "org.springframework.scheduling.quartz.CronTriggerBean" >
<property name ="jobDetail" >
<ref bean ="year_compute_entity" />
</property >
<property name ="cronExpression" >
<value > 0 55 23 12 31 ? * </value > <!-- 每年12月31号的23点55分触发 -->
</property >
</bean >

<!-- 管理触发器 -->
<bean autowire="no"
class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref local="day_cron" />
<ref local="month_cron" />
<ref local="year_cron" />
</list>
</property>
</bean>
可是运行的时候抛出了异常,异常如下:Cannot find class [org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean] for bean with name 'year_compute_entity' defined in ServletContext resource [/WEB-INF/daoContext.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean。我在spring的核心包里找了,好像没找到org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean这个类啊,可是网上所有的教程基本上都是这么写的,我想问的是org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean这个类是在spring的那个包里面,或者是在那个特定的版本里面?还有,我的配置文件有没有什么问题?麻烦各位大虾看看,指点一下,谢谢~~
...全文
评论 10
收藏 已收藏
分享
返回顶部
bmj
Web 开发 81,108 成员 341,721 内容