java - 如何解决 "Error creating bean with name ' 步骤 2' defined in class path resource "异常

标签 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();
}

最佳答案

您缺少spring-retry Classifier 的依赖 jar类

Spring Retry provides an abstraction around retrying failed operations

关于java - 如何解决 "Error creating bean with name ' 步骤 2' defined in class path resource "异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52050558/

相关文章:

java - hashCode() 和 identityHashCode() 如何在后端工作?

java - 构建 Java 浏览器时处理 CSS 和 JavaScript

java - 无法在 AsyncTask 中为 ProgressDialog 调用 Looper.prepare() 的线程内创建处理程序

spring - 没有 'org.springframework.batch.core.Job' 类型的合格 bean 可用 : expected single matching bean but found 2:

java - 如何从 spark 中设置和获取静态变量?

Java:如何处理可能需要大约 10 秒的 API 调用

java - NoClassDefFoundError : org/springframework/aop/framework/AbstractAdvisingBeanPostProcessor

java - 无法在 mongoTemplate springboot 中使用排序规则

java - Spring Batch writer 从下一行追加数据

java - 尝试编写 Spring Batch 单元测试时出现 NoSuchBeanDefinitionException