java - JSR 批处理 - 使用 @BatchProperty 进行构造函数注入
问题描述
我目前正在从事 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=)};
我在这里迷路了,我将不胜感激理解这种行为的任何帮助。
解决方案
批处理规范仅支持字段注入。因此,您的代码应更改为将批处理属性注入字段。例如,
@Inject
@BatchProperty
private String prop1;
批处理属性名称默认为 java 类字段名称。否则,您可以使用 指定名称@BatchProperty(name = "property-name")
。
推荐阅读
- css - Bootstrap 5 h-100 适用于 Chrome,Safari 无法获取图像组
- java - 如何调试 JSON 错误(发生在 Wordpress 后端)?
- amazon-web-services - AWS CDK Athena 数据源
- r - R中的嵌套for循环没有产生正确的迭代次数
- spring - 如何在 Spring Cloud Sleuth 中为命令行运行程序设置行李字段?
- python - 如何在 Python 中的不同行中显示多个结果?
- reactjs - 使用 useContext 重新加载页面会丢失 API 数据
- python - 列表弹出和插入在python中非常慢
- css - 如何叠加多个 gif 以在网页上创建深度?
- sql - ORA-00904 标识符无效:但列名有效