我使用spring-batch-admin-sample应用程序作为项目的起点。我有一个有效的弹簧批作业,它是用我正在与控制台集成的注释构建的。
当我把它装罐并将其添加到我的控制台项目时,注释不受尊重。为了对此进行测试,我已经将标记添加到作业中,因此尝试构建作业bean意味着已经看到并处理了annotation-config标记。
有人能看到我错过的东西吗?
提前致谢。
环境
OS: Windows 7
Java: jdk 1.8.0_25
Spring Batch Admin Sample version: 1.3.1
Spring version: 3.2.13 * stock 3.2.9 has a bug that causes this symptom
Spring-batch version: 3.0.2
Pivotal tc version: 3.0 Developer Edition
IDE: STS 3.6.3
记录剪辑:
14:27:13.667 [localhost-startStop-1] WARN ... Error creating bean with name 'step0002-fetch':
**Cannot resolve reference to bean 'sourceSelectionReader'**
while setting bean property 'itemReader'; nested exception is
org.springframework.beans.factory.NoSuchBeanDefinitionException:
No bean named 'sourceSelectionReader' is defined
作业Bean定义
<context:annotation-config/>
<bean class="org.springframework.batch.core.scope.StepScope" />
<batch:job id="my-job">
<batch:step id="step0002-fetch" >
<batch:tasklet transaction-manager="transactionManager" start-limit="100" >
<batch:chunk reader="sourceSelectionReader" writer="selectedDataWriter" commit-interval="1" />
</batch:tasklet>
<batch:next on="*" to="step0003-archive-purge"/>
</batch:step>
</batch:job
课程定义:
@Component("sourceSelectionReader")
@Scope(value="step", proxyMode = ScopedProxyMode.INTERFACES)
public class SourceSelectionReaderImpl
implements ItemReader<Object>,SourceSelectionReader, ApplicationContextAware {
...
}
答案 0 :(得分:1)
标签
<context:annotation-config/>
应该是
<context:component-scan/>
......寻找一块可以爬下来的岩石......
请参阅Difference between <context:annotation-config> vs <context:component-scan>以获取解释。