2014-10-16 84 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