spring3如何配置quartz2的jobListeners?
我用的spring版本是3.2.12.RELEASE,quartz版本是2.2.1spring配置:<!--配置job--><beanid="searchSplunkJo...
我用的spring版本是3.2.12.RELEASE,quartz版本是2.2.1
spring配置:
<!-- 配置job -->
<bean id="searchSplunkJob" class="org.springframework.scheduling.quartz.JobDetailFactoryBean">
<property name="jobClass" value="com.kuaiqian.test.job.SearchSplunkJob" />
<property name="jobDataAsMap">
<map>
<entry key="searchSplunkService"><ref bean="searchSplunkService" /></entry>
</map>
</property>
<property name="durability" value="true" />
</bean>
<bean id="searchSplunkJobTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
<property name="jobDetail">
<ref bean="searchSplunkJob" />
</property>
<property name="cronExpression" value="0 */1 * * * ?"/>
</bean>
<bean id="schedulerFactory" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="searchSplunkJobTrigger" />
</list>
</property>
<property name="jobListeners">
<list>
<ref bean="searchSplunkJobListener" />
</list>
</property>
</bean>
但是SchedulerFactoryBean中的jobListeners该如何配置呢?
我在相应的JobListener类中的getName()方法返回值就是"searchSplunkJobListener",JobListener类是个接口类型的,不知该如何在applicationContext.xml中注册这个类,请大家帮忙看看,谢谢! 展开
spring配置:
<!-- 配置job -->
<bean id="searchSplunkJob" class="org.springframework.scheduling.quartz.JobDetailFactoryBean">
<property name="jobClass" value="com.kuaiqian.test.job.SearchSplunkJob" />
<property name="jobDataAsMap">
<map>
<entry key="searchSplunkService"><ref bean="searchSplunkService" /></entry>
</map>
</property>
<property name="durability" value="true" />
</bean>
<bean id="searchSplunkJobTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
<property name="jobDetail">
<ref bean="searchSplunkJob" />
</property>
<property name="cronExpression" value="0 */1 * * * ?"/>
</bean>
<bean id="schedulerFactory" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="searchSplunkJobTrigger" />
</list>
</property>
<property name="jobListeners">
<list>
<ref bean="searchSplunkJobListener" />
</list>
</property>
</bean>
但是SchedulerFactoryBean中的jobListeners该如何配置呢?
我在相应的JobListener类中的getName()方法返回值就是"searchSplunkJobListener",JobListener类是个接口类型的,不知该如何在applicationContext.xml中注册这个类,请大家帮忙看看,谢谢! 展开
1个回答
展开全部
把下面的
<property name="jobListeners">
<list>
<ref bean="searchSplunkJobListener" />
</list>
</property>
删掉试一下
<property name="jobListeners">
<list>
<ref bean="searchSplunkJobListener" />
</list>
</property>
删掉试一下
追问
我就是要对这个job加监听器,每一次job跑完以后可以做一些操作
追答
myclass implements JobListener用自己的类实现这个接口然后把myclass以bean的形式定义到spring里面在searchSplunkJobListener这个地方把他换成自己定的myclass
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询