提到Spring Batch中的TaskletStep可以用来调用存储过程。谁能提供一个如何从 TaskletStep 调用存储过程的示例?到目前为止,我已经做到了这一点,但它抛出一个异常,说“配置问题:元素 [callStoredProcedure] 无法访问”
<job id="job1">
<step id="step1">
<tasklet ref="myTasklet"/>
</step>
</job>
<bean id="myTasklet" class="MyClass">
<property name="dataSource" ref="dataSource"/>
<property name="sql" value="call stored_procedure()"/>
</bean>
Java 类
class MyClass implements Tasklet{
@Override
public RepeatStatus execute(StepContribution contribution,
ChunkContext chunkContext) throws Exception {
JdbcTemplate myJDBC=new JdbcTemplate(getDataSource());
myJDBC.execute(sql);
return RepeatStatus.FINISHED;
}
}
存储过程应该如何配置以及在哪里配置?如果能收到任何指点,我将不胜感激?
而不是
value="call stored_procedure()"
就放
value="stored_procedure"
末尾没有 ()。这应该可以解决您的问题