Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 获取错误“;“尚未设置作业存储库”;尝试自动连接jobLauncher时_Java_Spring_Spring Mvc_Spring Batch - Fatal编程技术网

Java 获取错误“;“尚未设置作业存储库”;尝试自动连接jobLauncher时

Java 获取错误“;“尚未设置作业存储库”;尝试自动连接jobLauncher时,java,spring,spring-mvc,spring-batch,Java,Spring,Spring Mvc,Spring Batch,我目前正试图通过将jobLauncher自动连接到控制器来运行Spring批处理过程,这正是问题[here][1]的提问者想要做的。但是,我收到一个错误,告诉我autowire失败并且“作业存储库未设置””,这是由SimpleJobLauncher上的[AfterPropertieSet()方法][2]引起的。有人知道这是什么原因吗 下面是另一个asker的Spring配置,我也在使用它: <job id="writeProductsJob" xmlns="http://www.sp

我目前正试图通过将jobLauncher自动连接到控制器来运行Spring批处理过程,这正是问题[here][1]的提问者想要做的。但是,我收到一个错误,告诉我autowire失败并且“
作业存储库未设置”
”,这是由SimpleJobLauncher上的[AfterPropertieSet()方法][2]引起的。有人知道这是什么原因吗

下面是另一个asker的Spring配置,我也在使用它:

   <job id="writeProductsJob" xmlns="http://www.springframework.org/schema/batch">
        <step id="readWrite">
            <tasklet task-executor="taskExecutor">
                <chunk reader="productItemReader" writer="productItemWriter" commit-interval="10" />
            </tasklet>
        </step>
    </job>

    <bean id="taskExecutor"
        class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
        <property name="corePoolSize" value="5" />
        <property name="maxPoolSize" value="5" />
    </bean>

    <bean id="jobRepository"
        class="org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean">
        <property name="taskExecutor" ref="taskExecutor"/>
        <property name="transactionManager" ref="transactionManager" />
    </bean>


  [1]: http://stackoverflow.com/questions/9114162/spring-batch-starting-a-job-from-within-a-spring-mvc-contorller-with-a-new-thre
  [2]: http://grepcode.com/file/repo1.maven.org/maven2/org.springframework.batch/spring-batch-core/2.1.0.RELEASE/org/springframework/batch/core/launch/support/SimpleJobLauncher.java#SimpleJobLauncher.afterPropertiesSet%28%29

[1]: http://stackoverflow.com/questions/9114162/spring-batch-starting-a-job-from-within-a-spring-mvc-contorller-with-a-new-thre
[2]: http://grepcode.com/file/repo1.maven.org/maven2/org.springframework.batch/spring-batch-core/2.1.0.RELEASE/org/springframework/batch/core/launch/support/SimpleJobLauncher.java#SimpleJobLauncher.afterPropertiesSet%28%29
编辑:以下是TransactionManager、jobRepository和jobLauncher的配置:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.springframework.org/schema/beans 
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

  <bean id="transactionManager"
    class="org.springframework.batch.support.transaction.ResourcelessTransactionManager" />

  <bean id="jobRepository"
    class="org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean">
    <property name="transactionManager" ref="transactionManager" />
  </bean>

  <bean id="jobLauncher" 
    class="org.springframework.batch.core.launch.support.SimpleJobLauncher">
    <property name="jobRepository" ref="jobRepository" />
  </bean>
</beans>


你能为你的SimpleZoblancher添加配置吗?@MichaelMinella我刚刚在我的问题中添加了配置。你上面的配置现在有两个jobRepository bean定义(一个有taskExecutor,一个没有)。你用的是哪一个?或者你真的有两个定义?@MichaelMinella我真的有两个定义。我猜这会破坏它?在同一上下文中定义两个具有相同id的bean将破坏它。事实上,我很惊讶,在出现问题之前,您没有收到其他类似的错误。如果你重新命名一个,至少会有帮助。