【问题标题】:JSR batch - constructor injection using @BatchPropertyJSR 批处理 - 使用 @BatchProperty 的构造函数注入
【发布时间】:2020-07-14 22:00:53
【问题描述】:

我目前正在处理 JSR 批处理作业。我尝试在我的批处理构造函数中注入传入参数。

@Inject
public MyBatchLet(@BatchProperty(name="prop1") String prop1){
    this.myProperty = prop1;
}

这会引发依赖异常。

Unsatisfied dependency expressed through constructor argument with index 0 of type [java.lang.String]: : No qualifying bean of type [java.lang.String] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@javax.batch.api.BatchProperty(name=)};

我在这里迷路了,如果能帮助我理解这种行为,我将不胜感激。

【问题讨论】:

    标签: java spring-batch batch-processing jsr352


    【解决方案1】:

    批处理规范仅支持字段注入。因此,应更改您的代码以将批处理属性注入字段。例如,

    @Inject
    @BatchProperty
    private String prop1;
    
    

    批处理属性名默认为java类字段名。否则,您可以使用@BatchProperty(name = "property-name") 指定名称。

    【讨论】:

      猜你喜欢
      • 2014-07-15
      • 1970-01-01
      • 2013-01-30
      • 1970-01-01
      • 2017-03-07
      • 2012-06-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多