java cursor属性_java-在JdbcCursorItemReader中将作业参数用作准备好的语句参数

我有一个作业必须使用不同的作业参数运行多次.我想设置一个JdbcCursorItemReader来执行作业查询,itemReader的配置如下:

class="org.springframework.batch.item.database.JdbcCursorItemReader">

作业配置如下:

processor="tpsItemProcessor"

writer="tpsItemWriter" commit-interval="100000"/>

parameterSetter非常小:

package com.initech.reports.tps;

import java.sql.PreparedStatement;

import java.sql.sqlException;

import org.springframework.jdbc.core.PreparedStatementSetter;

public class ParameterSetter implements PreparedStatementSetter {

private final String x;

public ParameterSetter(String x) {this.x = x;}

@Override

public void setValues(PreparedStatement ps) throws sqlException {

ps.setString(1,x);

}

}

这是使用spring-batch 2.1.8.

如何将job参数放入查询中?

我想我接近了,我尝试将参数设置器配置更改为:

但是我得到这个错误:

Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 0): Field or property 'jobParameters' cannot be found on object of type 'org.springframework.beans.factory.config.BeanExpressionContext'

at org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty(PropertyOrFieldReference.java:208)

at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:72)

at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:52)

at org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:93)

at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:88)

at org.springframework.context.expression.StandardBeanExpressionResolver.evaluate(StandardBeanExpressionResolver.java:139)

... 51 more

我发现a very similar question,它与这个之间的区别是我没有要注释的阅读器类,我只有xml条目,因为我想避免不得不创建自己的itemReader. (我可以尝试重写jdbcCursorItemReader类,以便能够对其进行注释…)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值