[英]Spring Batch configuration NoSuchMethodError Exception
This is the first time I am using Spring batch and I have an exception : 这是我第一次使用Spring批处理,但有一个例外:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'stepScope' defined in class path resource [org/springframework/batch/core/configuration/annotation/StepScopeConfiguration.class]: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.springframework.batch.core.scope.StepScope org.springframework.batch.core.configuration.annotation.StepScopeConfiguration.stepScope()] threw exception; nested exception is java.lang.NoSuchMethodError: org.springframework.batch.core.scope.StepScope.setAutoProxy(Z)V
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:581)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1031)
....
Caused by: java.lang.NoSuchMethodError: org.springframework.batch.core.scope.StepScope.setAutoProxy(Z)V
at org.springframework.batch.core.configuration.annotation.StepScopeConfiguration.stepScope(AbstractBatchConfiguration.java:130)
I don't know how to solve this error. 我不知道如何解决这个错误。 I am using a Java configuration to define the job, the step, the reader, the processor and the writer :
我正在使用Java配置来定义作业,步骤,读取器,处理器和写入器:
public class SpringBatchTestJobConfig extends PersistenceSpringConfig {
@Autowired
private JobBuilderFactory jobBuilders;
@Autowired
private StepBuilderFactory stepBuilders;
@Bean
@StepScope
public FlatFileItemReader<EntiteJuridique> cvsReader(@Value("#{jobParameters[input.file]}") String input)
{
log.info("cvsReader");
FlatFileItemReader<EntiteJuridique> flatFileReader = new FlatFileItemReader<EntiteJuridique>();
flatFileReader.setLineMapper(lineMapper());
flatFileReader.setResource(new ClassPathResource(input));
return flatFileReader;
}
@Bean
public ItemWriter<EntiteJuridiqueJPA> writer()
{
log.info("writer");
JpaItemWriter<EntiteJuridiqueJPA> jpaWriter = new JpaItemWriter<EntiteJuridiqueJPA>();
try
{
jpaWriter.setEntityManagerFactory(entityManagerFactory().nativeEntityManagerFactory);
}
catch (Exception exception)
{
log.debug(exception);
}
return jpaWriter;
}
@Bean
public Job dataInitializer()
{
return jobBuilders.get("dataInitializer").start(step()).build();
}
@Bean
public Step step()
{
return stepBuilders.get("step").<EntiteJuridique, EntiteJuridiqueJPA> chunk(1).reader(cvsReader(null)).processor(processor())
.writer(writer()).build();
}
Any clues to how this problem? 这个问题怎么有线索?
EDIT : I am using 编辑:我正在使用
I got this same error, the solution for me was removing the version from my dependency and it worked fine. 我遇到了同样的错误,对我来说,解决方案是从我的依赖项中删除该版本,并且工作正常。
<dependency>
<groupId>org.springframework.batch</groupId>
<artifactId>spring-batch-core</artifactId>
</dependency>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.