如何解决“在类路径资源中定义名称为'step2'的bean创建错误”的异常

时间:2018-08-28 05:17:34

标签: java spring spring-batch noclassdeffounderror spring-retry

我的示例Spring Batch项目的step2()下面的方法在一台PC上工作正常,而在另一台PC上抛出以下错误。

有人可以解释我的代码有什么问题吗?

Error: org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'step2' defined in class path resource
[com/xxxx/yyy/configuration/CustomJobConfiguration.class]: Bean
instantiation via factory method failed; nested exception is
org.springframework.beans.BeanInstantiationException: Failed to
instantiate [org.springframework.batch.core.Step]: Factory method
'step2' threw exception; nested exception is
java.lang.NoClassDefFoundError:
org/springframework/classify/Classifier

方法:

@Bean
public Step step2() {
    System.out.println("Entering step2()");

    return stepBuilderFactory.get("step2")
            .<String, String>chunk(Integer.valueOf(chunkSize))
            .faultTolerant()
            .reader(reader())
            .writer(writer())
            .build();
}

1 个答案:

答案 0 :(得分:1)

您缺少spring-retry类的Classifier依赖关系罐

  

Spring Retry提供了有关重试失败操作的抽象