我使用以下作业启动器来启动我的弹簧批处理作业,我想运行一个名为Notify的类,我该如何配置它?
这是我的工作档案:
<context:component-scan base-package="com.mkyong" />
<!-- stored job-meta in memory -->
<bean id="jobRepository"
class="org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean">
<property name="transactionManager" ref="transactionManager" />
</bean>
<bean id="transactionManager" class="org.springframework.batch.support.transaction.ResourcelessTransactionManager" />
<bean id="jobLauncher"
class="org.springframework.batch.core.launch.support.SimpleJobLauncher">
<property name="jobRepository" ref="jobRepository" />
</bean>
<bean id="report" class="com.mkyong.model.Report" scope="prototype" />
<bean id="customWriter" class="com.mkyong.writers.CustomWriter" />
<bean id="notify" class="com.mkyong.model.Notify" />
<constructor-arg>
<bean class="org.springframework.batch.core.repository.dao.MapJobInstanceDao"/>
</constructor-arg>
</bean>
<bean id="runScheduler" class="com.mkyong.RunScheduler" />
<!-- Run every 5 seconds -->
<task:scheduled-tasks>
<!-- <task:scheduled ref="runScheduler" method="run" fixed-delay="5000"
/> -->
<task:scheduled ref="runScheduler" method="run"
cron="*/20 * * * * *" />
</task:scheduled-tasks>
</beans>
答案 0 :(得分:0)
你需要打电话给班级,你可以为此目的使用自动接线 -
然后你可以使用类的实例来调用类的相应方法。
@autowire
@qualifier('notify')
Notify nnotifyObject ;