gpt4 book ai didi

java - Spring 批处理 : Does a scope job exist

转载 作者:行者123 更新时间:2023-12-01 13:18:44 25 4
gpt4 key购买 nike

我得到了以下批处理作业:

<batch:job id="importPersonsJob" job-repository="jobRepository">
<batch:step id="importPersonStep">
<batch:tasklet transaction-manager="transactionManager">
<batch:chunk reader="personItemReader" writer="personItemWriter"
commit-interval="5" skip-limit="10">
<batch:skippable-exception-classes>
<batch:include class="java.lang.Throwable" />
</batch:skippable-exception-classes>
</batch:chunk>
<batch:listeners>
<batch:listener ref="skipListener" />
</batch:listeners>
</batch:tasklet>
</batch:step>
<batch:listeners>
<batch:listener ref="authenticationJobListener" />
<batch:listener ref="jobListener" />
</batch:listeners>
</batch:job>

我需要访问skipListener 和jobListener 中的JobParameters。为此,我尝试了以下方法:

<bean id="skipListener" class="job.batch.listener.Log4JSkipListener" scope="step">
<property name="logPath" value="#{jobParameters['logPath']}" />
</bean>

<bean id="jobListener" class="job.batch.listener.JobListener" scope="job">
<property name="propertyAccessManager" ref="propertyAccessManager" />
<property name="logPath" value="#{jobParameters['logPath']}" />
</bean>

当我遇到异常时,它似乎适用于skipListener:

 [java] Caused by: java.lang.IllegalStateException: No Scope registered for scope 'job'
[java] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:325)
[java] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
[java] at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
[java] at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
[java] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1360)
[java] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118)
[java] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
[java] ... 43 more

范围作业不存在吗?我在这个page上找到了它。知道如何解决我的问题吗?我什至尝试使用 scope=batch,这导致了同样的异常。

这是 ivy 的依赖项:

<dependency org="org.springframework.batch" name="spring-batch-core" rev="2.1.9.RELEASE" conf="default->default">
<exclude org="org.aspectj" name="aspectjweaver"/>
</dependency>

最佳答案

您发布的 API 文档链接显示“自 3.0 起”,因此我想您必须使用 Spring Batch 3.0(我认为尚未正式发布)。

关于java - Spring 批处理 : Does a scope job exist,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22230481/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com