如何在spring批处理中编写自定义项读取器

如何在spring批处理中编写自定义项读取器,spring,spring-batch,Spring,Spring Batch,我是SpringBatch的新手,我需要在SpringBatch中自定义ItemReaders。我该怎么做?我的要求是我有来自多个源系统的提要,这些提要存储在不同的暂存表中。现在,根据源系统,我必须查询相应的暂存表。为此,我需要编写一个自定义ItemReader。有人能帮我吗。查看下面的文档第6.9点 您必须创建rowmapper并使用JdbcCursorItemReader或JdbcPagingItemReader还有其他使用JPA和hibernate的选项,如果您从不同的表中读取,您可以使

我是SpringBatch的新手,我需要在SpringBatch中自定义ItemReaders。我该怎么做?我的要求是我有来自多个源系统的提要,这些提要存储在不同的暂存表中。现在,根据源系统,我必须查询相应的暂存表。为此,我需要编写一个自定义ItemReader。有人能帮我吗。

查看下面的文档第6.9点

您必须创建rowmapper并使用JdbcCursorItemReader或JdbcPagingItemReader还有其他使用JPA和hibernate的选项,如果您从不同的表中读取,您可以使视图连接所有这些表

import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.NonTransientResourceException;
import org.springframework.batch.item.ParseException;
import org.springframework.batch.item.UnexpectedInputException;


public class YoutItemReader implements ItemReader<YourObject> {

    @Override
    public YourObject read() throws Exception, UnexpectedInputException, ParseException, NonTransientResourceException {

        // You Code Here
        YourObject oa = new YourObject();
        return oa;
    }

}
import org.springframework.batch.item.ItemReader;
导入org.springframework.batch.item.NonTransientResourceException;
导入org.springframework.batch.item.ParseException;
导入org.springframework.batch.item.UnexpectedInputException;
公共类YoutItemReader实现ItemReader{
@凌驾
public YourObject read()引发异常、UnexpectedInputException、ParseException、NonTransientResourceException{
//你在这里编码
YourObject oa=新建YourObject();
返回oa;
}
}

您可以分享您当前的工作状态吗?您可以使用委托或直接实现
ItemReader
接口来编写自己的阅读器。请更详细地说明您失败的尝试,我们可以以更好的方式帮助您