我试图访问我的RowMapper中的StepExecution,但无法这样做。我有一个名为'prop1'的xml属性集。我期望这个设置,但它不是setting.I还向RowMapper添加了一个@BeforeStep方法,希望我可以得到stepExecutionContext,但这个方法永远不会被调用。还有什么我需要做的吗?无法设置/获取rowMapper中的属性值
这里是我的xml:
<bean id="bean1"
class="org.springframework.batch.item.database.JdbcCursorItemReader"
scope="step">
<property name="dataSource" ref="dataSource" />
<property name="sql"
value="${sql}"/>
<property name="fetchSize" value="${fetchSize}"></property>
<property name="rowMapper">
<bean id="rowMapper1" class="c.p.MyRowMapper" scope="step">
<property name="prop1" value="${prop1}"></property>
</property>
这里是我的RowMapper:
public class MyRowMapper implements RowMapper<Object>{
private String prop1;
private StepExecution se;
public String getProp1() {
return stepFatpCount;
}
public void setProp1(String rop1) {
this. prop1 = prop1;
}
@BeforeStep
public void beforeStep(StepExecution stepExecution){
this.se = stepExecution;
}
}
我有一些属性这一步又一步之前在stepExecutionContext设置,我想在RowMapper中使用它们。同样的事情在ItemProcessor中工作,但不在RowMapper中。请让我知道如果我需要为懒惰绑定或任何其他问题做更多的事情。 谢谢。
感谢您的回复。是的,我的意思是JobExecutionContext而不是步骤,但是我想从RowMapper中的stepExecution访问jobExecutionContext。 – sandesh
但是,如何访问RowMapper中的prop1?我有setter/getter,但我没有看到设置的值。任何帮助? – sandesh
所以属性prop1的值实际上是设置的。那很好。但是我仍然无法访问rowMapper中的stepExecutionContext或jobExecutionContext – sandesh