2014-10-16 88 views
0

任何人都可以提供详细信息,了解如何通过提供需要的作业名称来实现“JobNameToJobRestartRequestAdapter”类API以重新启动失败的作业被执行。使用“org.springframework.batch.admin.integration.JobNameToJobRestartRequestAdapter”重新启动批量作业

我创建上下文xml文件

<int:channel id="job-launches" /> 
    <int:channel id="job-restarts" /> 

    <int:service-activator id="restartJobClassProperties" input-channel="job-restarts" output-channel="job-requests"> 
     <bean class="org.springframework.batch.admin.integration.JobNameToJobRestartRequestAdapter"> 
      <property name="jobLocator" ref="jobRegistry" /> 
      <property name="jobExplorer" ref="jobExplorer" /> 
     </bean> 
    </int:service-activator> 

    <bean id="jobRegistry" class="org.springframework.batch.core.configuration.JobLocator"> 
     <property name="name" value="JobNameGoesHere" /> 
    </bean> 

    <bean id="jobExplorer" class="org.springframework.batch.core.explore.JobExplorer" /> 

在执行其正在读我得到下面的错误该context.xml文件主类:

与名

错误创建豆

'org.springframework.integration.config.ServiceActivatorFactoryBean#0': Cannot create inner bean 'org.springframework.batch.admin.integration.JobNameToJobRestartRequestAdapter#0' of type [org.springframework.batch.admin.integration.JobNameToJobRestartRequestAdapter] while setting bean property 'targetObject'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.batch.admin.integration.JobNameToJobRestartRequestAdapter#0' defined in class path resource [META-INF/spring/restart-job-context.xml]: Cannot resolve reference to bean 'jobRegistry' while setting bean property 'jobLocator'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jobRegistry' defined in class path resource [META-INF/spring/restart-job-context.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.batch.core.configuration.JobLocator]: Specified class is an interface

我想要实现用于定义批处理作业名称的功能,我希望重新启动它,并且可以从jobexplorer中提取属性最后执行的步骤。

回答

0

JobLocator是一个接口。你不能定义一个只是一个接口的bean。我想你想用JobRegistry。下面就是Spring Batch的系统管理员使用。

<bean id="jobLoader" class="org.springframework.batch.core.configuration.support.AutomaticJobRegistrar"> 
    <property name="applicationContextFactories"> 
     <bean class="org.springframework.batch.core.configuration.support.ClasspathXmlApplicationContextsFactoryBean"> 
      <property name="resources" value="classpath*:/META-INF/spring/batch/jobs/*.xml" /> 
     </bean> 
    </property> 
    <property name="jobLoader"> 
     <bean class="org.springframework.batch.core.configuration.support.DefaultJobLoader"> 
      <property name="jobRegistry" ref="jobRegistry" /> 
     </bean> 
    </property> 
</bean> 

<bean id="jobRegistry" class="org.springframework.batch.core.configuration.support.MapJobRegistry" /> 

jobRegistry豆是从(它确实实现JobLocator中查找作业注册表与注册表jobLoader寄存器作业定义

+0

感谢。细节,我仍然没有得到如何通过需要从最后一个失败的步骤重新启动的作业名称。 – 2014-10-22 20:28:53