定义 Bean 时没有合格的 Bean
No Qualifying Bean When Bean is Defined
我一直在尝试进行设置,在其中创建实现 JdbcCursorItemReader 的 PostDatedAchInReader,然后将其注入 PostDatedAchInAggregatingJdbcItemReader,后者根据特定条件收集读取对象并将它们分组到一个列表中,基本上保留所有 ach 请求组通过客户端 ID。但是,我一直收到没有合格的 bean 错误,但 bean 在这里并已定义。我对问题是什么或如何解决感到困惑。
所以我有如下配置文件
@Configuration
public class PostDatedAchInBatchConfig extends AbstractCommonBatchJobConfig {
private static final String ACH_FULFILLMENT_POST_DATED_ACH_IN_STEP1_NAME =
"achFulfillment_postDatedAchInJob_step1_scheduleAchIns";
@Autowired
DataSource prodDataSource;
/**
* This method defines the Job.
*
* @return postdatedachinjob
* return the configured job.
*/
@Bean(name = "achFulfillmentPostDatedAchInJob")
public Job job() throws Exception {
mmLogMgr.info("AchFulfillmentEmailBatchConfig : job");
return getJobBuilderFactory().get("achFulfillmentPostDatedAchInJob")
.listener(postDatedAchInListener())
.start(step1())
.on(ExitStatus.COMPLETED.getExitCode())
.end() // end of TransactionBuilder
.end() // end of FlowBuilder
.build();
}
..
/**
* @return postDatedAchInAggregatingJdbcItemReader.
*/
@Bean
@Scope(value = "step", proxyMode = ScopedProxyMode.DEFAULT)
public ItemReader<ArrayList<PostDatedAchIn>> postDatedAchInAggregatingJdbcItemReader(@Qualifier("postDatedAchInReader") final PostDatedAchInReader postDatedAchInReader)
throws Exception {
PostDatedAchInAggregatingJdbcItemReader postDatedAchInAggregatingJdbcItemReader =
new PostDatedAchInAggregatingJdbcItemReader();
postDatedAchInAggregatingJdbcItemReader.setDatabaseItemReader(postDatedAchInReader);
return postDatedAchInAggregatingJdbcItemReader;
}
@Bean
public PostDatedAchInClassifierWriter postDatedAchInClassifierWriter() {
Map<String, ItemWriter<PostDatedAchIn>> classMap = new HashMap<String, ItemWriter<PostDatedAchIn>>();
classMap.put("true", postDatedAchInCompositeWriterOneTimeFailure());
classMap.put("false", postDatedAchInCompositeWriterPosted());
PostDatedAchInClassifierWriter classifyWriter = new PostDatedAchInClassifierWriter();
classifyWriter.setClassMap(classMap);
return classifyWriter;
}
..
@Bean(name = "postDatedAchInReader")
@Scope(value = "step", proxyMode = ScopedProxyMode.DEFAULT)
public PostDatedAchInReader postDatedAchInReader(@Value("#{jobExecutionContext['current.business.date']}") final String currentBusinessDate) {
SqlStatementHelper sqlStatementHelper = new SqlStatementHelper(PostDatedAchInConstants.POST_DATED_ACH_IN_PROPERTY_FILE,
PostDatedAchInConstants.POST_DATED_ACH_IN_PROPERTY_ALT_FILE);
String sqlStatement = sqlStatementHelper.getSqlStatement(PostDatedAchInConstants.RETRIEVE_POST_DATED_ACH_IN);
ArrayList<String> parameters = new ArrayList<String>();
parameters.add(currentBusinessDate);
parameters.add(currentBusinessDate);
parameters.add(currentBusinessDate);
ListPreparedStatementSetter preparedStatementSetter = new ListPreparedStatementSetter();
preparedStatementSetter.setParameters(parameters);
PostDatedAchInReader postDatedAchInReader = new PostDatedAchInReader();
postDatedAchInReader.setDataSource(prodDataSource);
postDatedAchInReader.setSql(sqlStatement);
postDatedAchInReader.setRowMapper(new PostDatedAchInRowMapper());
postDatedAchInReader.setPreparedStatementSetter(preparedStatementSetter);
return postDatedAchInReader;
}
/**
* This method defines the Steps, it writes 1 record at a time.
*
* @return postdatedachinjob_step1
*
*/
@Bean(name = ACH_FULFILLMENT_POST_DATED_ACH_IN_STEP1_NAME)
public Step step1() throws Exception {
mmLogMgr.info(ACH_FULFILLMENT_POST_DATED_ACH_IN_STEP1_NAME);
return getStepBuilderFactory().get(ACH_FULFILLMENT_POST_DATED_ACH_IN_STEP1_NAME)
.<ArrayList<PostDatedAchIn>, ArrayList<PostDatedAchIn>> chunk(AchFulfillmentBatchJobUtil
.getChunkValue("postdatedachin"))
.reader(postDatedAchInAggregatingJdbcItemReader(null))
.processor(postDatedAchInProcessor())
.writer(postDatedAchInClassifierWriter())
.build();
}
}
当我 运行 作业时,我得到以下堆栈跟踪:
2018-10-31 15:06:45,821 ERROR [o.s.batch.core.step.AbstractStep:AbstractStep.java:execute:229 - main] - Encountered an error executing step achFulfillment_postDatedAchInJob_step1_scheduleAchIns in job achFulfillmentPostDatedAchInJob
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'scopedTarget.postDatedAchInAggregatingJdbcItemReader' defined in com.tdameritrade.ctg.ach.batch.postdatedachinjob.PostDatedAchInBatchConfig: Unsatisfied dependency expressed through method 'postDatedAchInAggregatingJdbcItemReader' parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.tdameritrade.ctg.ach.batch.postdatedachinjob.PostDatedAchInReader' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Qualifier(value=postDatedAchInReader)}
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:749)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:467)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1173)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1067)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.AbstractBeanFactory.getObject(AbstractBeanFactory.java:345)
at org.springframework.batch.core.scope.StepScope.get(StepScope.java:113)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:340)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.aop.target.SimpleBeanTargetSource.getTarget(SimpleBeanTargetSource.java:35)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:192)
at com.sun.proxy.$Proxy112.read(Unknown Source)
at org.springframework.batch.core.step.item.SimpleChunkProvider.doRead(SimpleChunkProvider.java:91)
at org.springframework.batch.core.step.item.SimpleChunkProvider.read(SimpleChunkProvider.java:157)
at org.springframework.batch.core.step.item.SimpleChunkProvider.doInIteration(SimpleChunkProvider.java:116)
at org.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatTemplate.java:374)
at org.springframework.batch.repeat.support.RepeatTemplate.executeInternal(RepeatTemplate.java:215)
at org.springframework.batch.repeat.support.RepeatTemplate.iterate(RepeatTemplate.java:144)
at org.springframework.batch.core.step.item.SimpleChunkProvider.provide(SimpleChunkProvider.java:110)
at org.springframework.batch.core.step.item.ChunkOrientedTasklet.execute(ChunkOrientedTasklet.java:69)
at org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:406)
at org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:330)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133)
at org.springframework.batch.core.step.tasklet.TaskletStep.doInChunkContext(TaskletStep.java:272)
at org.springframework.batch.core.scope.context.StepContextRepeatCallback.doInIteration(StepContextRepeatCallback.java:81)
at org.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatTemplate.java:374)
at org.springframework.batch.repeat.support.RepeatTemplate.executeInternal(RepeatTemplate.java:215)
at org.springframework.batch.repeat.support.RepeatTemplate.iterate(RepeatTemplate.java:144)
at org.springframework.batch.core.step.tasklet.TaskletStep.doExecute(TaskletStep.java:257)
at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:200)
at org.springframework.batch.core.job.SimpleStepHandler.handleStep(SimpleStepHandler.java:148)
at org.springframework.batch.core.job.flow.JobFlowExecutor.executeStep(JobFlowExecutor.java:64)
at org.springframework.batch.core.job.flow.support.state.StepState.handle(StepState.java:67)
at org.springframework.batch.core.job.flow.support.SimpleFlow.resume(SimpleFlow.java:169)
at org.springframework.batch.core.job.flow.support.SimpleFlow.start(SimpleFlow.java:144)
at org.springframework.batch.core.job.flow.FlowJob.doExecute(FlowJob.java:134)
at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:306)
at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:135)
at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:50)
at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:128)
at com.tdameritrade.ctg.ach.fulfillment.util.MoneyMovementHelper.getJobExecution(MoneyMovementHelper.java:155)
at com.tdameritrade.ctg.ach.fulfillment.util.MoneyMovementHelper.getJobExecution(MoneyMovementHelper.java:136)
at com.tdameritrade.ctg.ach.batch.postdatedachinjob.PostDatedAchInBatchConfigTest.testLaunchJob(PostDatedAchInBatchConfigTest.java:32)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:252)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94)
at org.junit.runners.ParentRunner.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access[=11=]0(ParentRunner.java:58)
at org.junit.runners.ParentRunner.evaluate(ParentRunner.java:268)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.tdameritrade.ctg.ach.batch.postdatedachinjob.PostDatedAchInReader' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Qualifier(value=postDatedAchInReader)}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1493)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1104)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:835)
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741)
... 72 common frames omitted
我很困惑,当它在 class.
中定义时,它怎么说找不到该类型的 bean
我该如何解决这个问题?
因此,我们能够通过在步骤配置中更改对聚合 reader 的调用来发送游标 reader 的 method/bean 来解决此问题。我们更改了这一行:
.reader(postDatedAchInAggregatingJdbcItemReader(postDatedAchInReader()))
并删除了@Qualifier。这阻止了这个错误,并且它确实正确地连接了所有东西。对我来说感觉有点笨重,但它确实有效。如果有人有其他解决方案,我愿意接受。
我一直在尝试进行设置,在其中创建实现 JdbcCursorItemReader 的 PostDatedAchInReader,然后将其注入 PostDatedAchInAggregatingJdbcItemReader,后者根据特定条件收集读取对象并将它们分组到一个列表中,基本上保留所有 ach 请求组通过客户端 ID。但是,我一直收到没有合格的 bean 错误,但 bean 在这里并已定义。我对问题是什么或如何解决感到困惑。
所以我有如下配置文件
@Configuration
public class PostDatedAchInBatchConfig extends AbstractCommonBatchJobConfig {
private static final String ACH_FULFILLMENT_POST_DATED_ACH_IN_STEP1_NAME =
"achFulfillment_postDatedAchInJob_step1_scheduleAchIns";
@Autowired
DataSource prodDataSource;
/**
* This method defines the Job.
*
* @return postdatedachinjob
* return the configured job.
*/
@Bean(name = "achFulfillmentPostDatedAchInJob")
public Job job() throws Exception {
mmLogMgr.info("AchFulfillmentEmailBatchConfig : job");
return getJobBuilderFactory().get("achFulfillmentPostDatedAchInJob")
.listener(postDatedAchInListener())
.start(step1())
.on(ExitStatus.COMPLETED.getExitCode())
.end() // end of TransactionBuilder
.end() // end of FlowBuilder
.build();
}
..
/**
* @return postDatedAchInAggregatingJdbcItemReader.
*/
@Bean
@Scope(value = "step", proxyMode = ScopedProxyMode.DEFAULT)
public ItemReader<ArrayList<PostDatedAchIn>> postDatedAchInAggregatingJdbcItemReader(@Qualifier("postDatedAchInReader") final PostDatedAchInReader postDatedAchInReader)
throws Exception {
PostDatedAchInAggregatingJdbcItemReader postDatedAchInAggregatingJdbcItemReader =
new PostDatedAchInAggregatingJdbcItemReader();
postDatedAchInAggregatingJdbcItemReader.setDatabaseItemReader(postDatedAchInReader);
return postDatedAchInAggregatingJdbcItemReader;
}
@Bean
public PostDatedAchInClassifierWriter postDatedAchInClassifierWriter() {
Map<String, ItemWriter<PostDatedAchIn>> classMap = new HashMap<String, ItemWriter<PostDatedAchIn>>();
classMap.put("true", postDatedAchInCompositeWriterOneTimeFailure());
classMap.put("false", postDatedAchInCompositeWriterPosted());
PostDatedAchInClassifierWriter classifyWriter = new PostDatedAchInClassifierWriter();
classifyWriter.setClassMap(classMap);
return classifyWriter;
}
..
@Bean(name = "postDatedAchInReader")
@Scope(value = "step", proxyMode = ScopedProxyMode.DEFAULT)
public PostDatedAchInReader postDatedAchInReader(@Value("#{jobExecutionContext['current.business.date']}") final String currentBusinessDate) {
SqlStatementHelper sqlStatementHelper = new SqlStatementHelper(PostDatedAchInConstants.POST_DATED_ACH_IN_PROPERTY_FILE,
PostDatedAchInConstants.POST_DATED_ACH_IN_PROPERTY_ALT_FILE);
String sqlStatement = sqlStatementHelper.getSqlStatement(PostDatedAchInConstants.RETRIEVE_POST_DATED_ACH_IN);
ArrayList<String> parameters = new ArrayList<String>();
parameters.add(currentBusinessDate);
parameters.add(currentBusinessDate);
parameters.add(currentBusinessDate);
ListPreparedStatementSetter preparedStatementSetter = new ListPreparedStatementSetter();
preparedStatementSetter.setParameters(parameters);
PostDatedAchInReader postDatedAchInReader = new PostDatedAchInReader();
postDatedAchInReader.setDataSource(prodDataSource);
postDatedAchInReader.setSql(sqlStatement);
postDatedAchInReader.setRowMapper(new PostDatedAchInRowMapper());
postDatedAchInReader.setPreparedStatementSetter(preparedStatementSetter);
return postDatedAchInReader;
}
/**
* This method defines the Steps, it writes 1 record at a time.
*
* @return postdatedachinjob_step1
*
*/
@Bean(name = ACH_FULFILLMENT_POST_DATED_ACH_IN_STEP1_NAME)
public Step step1() throws Exception {
mmLogMgr.info(ACH_FULFILLMENT_POST_DATED_ACH_IN_STEP1_NAME);
return getStepBuilderFactory().get(ACH_FULFILLMENT_POST_DATED_ACH_IN_STEP1_NAME)
.<ArrayList<PostDatedAchIn>, ArrayList<PostDatedAchIn>> chunk(AchFulfillmentBatchJobUtil
.getChunkValue("postdatedachin"))
.reader(postDatedAchInAggregatingJdbcItemReader(null))
.processor(postDatedAchInProcessor())
.writer(postDatedAchInClassifierWriter())
.build();
}
}
当我 运行 作业时,我得到以下堆栈跟踪:
2018-10-31 15:06:45,821 ERROR [o.s.batch.core.step.AbstractStep:AbstractStep.java:execute:229 - main] - Encountered an error executing step achFulfillment_postDatedAchInJob_step1_scheduleAchIns in job achFulfillmentPostDatedAchInJob
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'scopedTarget.postDatedAchInAggregatingJdbcItemReader' defined in com.tdameritrade.ctg.ach.batch.postdatedachinjob.PostDatedAchInBatchConfig: Unsatisfied dependency expressed through method 'postDatedAchInAggregatingJdbcItemReader' parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.tdameritrade.ctg.ach.batch.postdatedachinjob.PostDatedAchInReader' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Qualifier(value=postDatedAchInReader)}
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:749)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:467)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1173)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1067)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.AbstractBeanFactory.getObject(AbstractBeanFactory.java:345)
at org.springframework.batch.core.scope.StepScope.get(StepScope.java:113)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:340)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.aop.target.SimpleBeanTargetSource.getTarget(SimpleBeanTargetSource.java:35)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:192)
at com.sun.proxy.$Proxy112.read(Unknown Source)
at org.springframework.batch.core.step.item.SimpleChunkProvider.doRead(SimpleChunkProvider.java:91)
at org.springframework.batch.core.step.item.SimpleChunkProvider.read(SimpleChunkProvider.java:157)
at org.springframework.batch.core.step.item.SimpleChunkProvider.doInIteration(SimpleChunkProvider.java:116)
at org.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatTemplate.java:374)
at org.springframework.batch.repeat.support.RepeatTemplate.executeInternal(RepeatTemplate.java:215)
at org.springframework.batch.repeat.support.RepeatTemplate.iterate(RepeatTemplate.java:144)
at org.springframework.batch.core.step.item.SimpleChunkProvider.provide(SimpleChunkProvider.java:110)
at org.springframework.batch.core.step.item.ChunkOrientedTasklet.execute(ChunkOrientedTasklet.java:69)
at org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:406)
at org.springframework.batch.core.step.tasklet.TaskletStep$ChunkTransactionCallback.doInTransaction(TaskletStep.java:330)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133)
at org.springframework.batch.core.step.tasklet.TaskletStep.doInChunkContext(TaskletStep.java:272)
at org.springframework.batch.core.scope.context.StepContextRepeatCallback.doInIteration(StepContextRepeatCallback.java:81)
at org.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatTemplate.java:374)
at org.springframework.batch.repeat.support.RepeatTemplate.executeInternal(RepeatTemplate.java:215)
at org.springframework.batch.repeat.support.RepeatTemplate.iterate(RepeatTemplate.java:144)
at org.springframework.batch.core.step.tasklet.TaskletStep.doExecute(TaskletStep.java:257)
at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:200)
at org.springframework.batch.core.job.SimpleStepHandler.handleStep(SimpleStepHandler.java:148)
at org.springframework.batch.core.job.flow.JobFlowExecutor.executeStep(JobFlowExecutor.java:64)
at org.springframework.batch.core.job.flow.support.state.StepState.handle(StepState.java:67)
at org.springframework.batch.core.job.flow.support.SimpleFlow.resume(SimpleFlow.java:169)
at org.springframework.batch.core.job.flow.support.SimpleFlow.start(SimpleFlow.java:144)
at org.springframework.batch.core.job.flow.FlowJob.doExecute(FlowJob.java:134)
at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:306)
at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:135)
at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:50)
at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:128)
at com.tdameritrade.ctg.ach.fulfillment.util.MoneyMovementHelper.getJobExecution(MoneyMovementHelper.java:155)
at com.tdameritrade.ctg.ach.fulfillment.util.MoneyMovementHelper.getJobExecution(MoneyMovementHelper.java:136)
at com.tdameritrade.ctg.ach.batch.postdatedachinjob.PostDatedAchInBatchConfigTest.testLaunchJob(PostDatedAchInBatchConfigTest.java:32)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:252)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94)
at org.junit.runners.ParentRunner.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access[=11=]0(ParentRunner.java:58)
at org.junit.runners.ParentRunner.evaluate(ParentRunner.java:268)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.tdameritrade.ctg.ach.batch.postdatedachinjob.PostDatedAchInReader' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Qualifier(value=postDatedAchInReader)}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1493)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1104)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:835)
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741)
... 72 common frames omitted
我很困惑,当它在 class.
中定义时,它怎么说找不到该类型的 bean我该如何解决这个问题?
因此,我们能够通过在步骤配置中更改对聚合 reader 的调用来发送游标 reader 的 method/bean 来解决此问题。我们更改了这一行:
.reader(postDatedAchInAggregatingJdbcItemReader(postDatedAchInReader()))
并删除了@Qualifier。这阻止了这个错误,并且它确实正确地连接了所有东西。对我来说感觉有点笨重,但它确实有效。如果有人有其他解决方案,我愿意接受。