Java 使用“org.springframework.batch.admin.integration.JobNameToJobRestartRequestAdapter”重新启动批处理作业

Java 使用“org.springframework.batch.admin.integration.JobNameToJobRestartRequestAdapter”重新启动批处理作业,java,spring,spring-batch,restart,Java,Spring,Spring Batch,Restart,任何人都可以提供详细信息,如如何通过提供需要执行的作业的名称来实现JobNameToJobRestartRequestAdapter类API以重新启动失败的作业 我创建了上下文xml文件 <int:channel id="job-launches" /> <int:channel id="job-restarts" /> <int:service-activator id="restartJobClassProperties" input

任何人都可以提供详细信息,如如何通过提供需要执行的作业的名称来实现JobNameToJobRestartRequestAdapter类API以重新启动失败的作业

我创建了上下文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文件的主类时,出现以下错误:

创建名为的bean时出错

“org.springframework.integration.config.ServiceActivatorFactoryBean0”: 无法创建内部bean 'org.springframework.batch.admin.integration.JobNameToJobRestartRequestAdapter0' 类型 [org.springframework.batch.admin.integration.JobNameToJobRestartRequestAdapter] 设置bean属性“targetObject”时;嵌套异常是 org.springframework.beans.factory.BeanCreationException:错误 创建名为的bean 'org.springframework.batch.admin.integration.JobNameToJobRestartRequestAdapter0' 在类路径资源中定义 [META-INF/spring/restart job context.xml]:无法解析对的引用 设置bean属性“jobLocator”时使用bean“jobRegistry”;嵌套 例外情况为org.springframework.beans.factory.BeanCreationException: 创建类路径中定义了名为“jobRegistry”的bean时出错 资源[META-INF/spring/restart job context.xml]:的实例化 bean失败;嵌套异常是 org.springframework.beans.BeanInstantiationException:无法 实例化bean类 [org.springframework.batch.core.configuration.JobLocator]:指定 类是一个接口

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

JobLocator是一个接口。您不能定义一个仅仅是接口的bean。我想你应该使用工作注册。以下是Spring Batch Admin使用的内容:

<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 bean是要从中查找的作业的注册表,它实现了JobLocator。jobLoader在注册表中注册作业定义。

感谢您提供的详细信息,我仍然不知道如何传递需要从上一个失败步骤重新启动的作业名称。