Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用spring批处理将JPARepository与ItemReader连接?_Spring_Spring Batch_Batch Processing - Fatal编程技术网

如何使用spring批处理将JPARepository与ItemReader连接?

如何使用spring批处理将JPARepository与ItemReader连接?,spring,spring-batch,batch-processing,Spring,Spring Batch,Batch Processing,我需要使用SpringBatch从ItemReader连接jpa存储库,以便将数据库导出到文本文件。但到目前为止,我尝试使用JdbcCursorItemReader类从数据库中检索数据。我需要使用SpringDataJPA连接存储库 下面是我使用的代码 @Bean public ItemReader<Object> databaseCsvItemReader(@Qualifier("dataSource") DataSource dataSource) throws

我需要使用SpringBatch从ItemReader连接jpa存储库,以便将数据库导出到文本文件。但到目前为止,我尝试使用JdbcCursorItemReader类从数据库中检索数据。我需要使用SpringDataJPA连接存储库

下面是我使用的代码

    @Bean
    public ItemReader<Object> databaseCsvItemReader(@Qualifier("dataSource") DataSource dataSource) throws Exception {
        JdbcCursorItemReader<Object> reader = new JdbcCursorItemReader<Object>();
        reader.setSql(QUERY);
        reader.setDataSource(dataSource);
        reader.setRowMapper(new BeanPropertyRowMapper<>(Object.class));
        return reader;

    }
@Bean
public ItemReader databaseCsvItemReader(@Qualifier(“dataSource”)dataSource dataSource)引发异常{
JdbcCursorItemReader=新的JdbcCursorItemReader();
reader.setSql(查询);
reader.setDataSource(数据源);
setRowMapper(新的BeanPropertyRowMapper(Object.class));
返回读取器;
}
从这个读者那里,我需要使用Jpa而不是普通的jdbc进行连接,任何人都可以在这方面帮助我,或者它可能会帮助我使用Jpa

我需要使用SpringDataJPA连接存储库

这就是你要找的。它允许您使用Spring数据存储库来读取项目

你可以找到如何使用它的例子