spring-batch 相关问题

Spring Batch是一个轻量级,全面的框架,旨在实现对企业系统日常运营至关重要的批处理应用程序的开发。此上下文中的批处理应用程序是指针对批量数据处理的自动离线系统。

如何在 Spring Batch 5.x 中对记录进行分组,以便每个线程/执行专用于一组记录

我正在使用 Spring Batch 5 & 我有一个用例,我需要根据 bookingId 对输入记录(来自数据库)进行分组。现在处理器应该从读取器中逐组挑选记录

回答 2 投票 0

如何在意外关闭时更新 Spring Batch 状态

我正在实现一项服务,如果现有作业正在运行,该服务将拒绝处理作业请求。不幸的是,我不确定是否有办法区分工作与...

回答 1 投票 0

spring批处理-使用FlatFileItemWriter将数据导出到csv

我尝试导出 csv 文件,但发现错误,所有值都设置为一列,而不是两列或三列,这是输出示例: 在此输入图像描述 导出文件的java代码:

回答 1 投票 0

在 Spring Batch itemReader 中从流而不是文件中读取

我收到一个 csv 文件作为需要加载的 Web 服务调用。现在我将其保存在临时目录中,以将其作为 setResource 提供给 Reader。 有没有办法提供stream(byte[]) a...

回答 2 投票 0

spring批处理+spring boot+java配置+测试用例

spring批处理+spring boot+java配置+测试用例 我遵循了下面的示例,我的用例与此匹配,我已经使用类似的设置实现了该项目,一切正常。 我结构...

回答 3 投票 0

在 Spring Batch 中重新启动分区步骤

我们的应用程序是在 openshift 中运行的 Spring 批处理。应用程序通过 REST 调用另一个服务来从数据库中获取记录。两者都使用 nginx side car 来处理流量。两侧车

回答 1 投票 0

Spring 批处理作业已经运行但无法正常工作

我正在使用 Spring Batch 5。如果该批处理已经在运行,我需要再次停止运行该批处理。我试过如下 作业配置: @成分 @RequiredArgsConstructor @Slf4j 公共...

回答 1 投票 0

如何让Spring Batch作业只执行一次

我是 Spring Batch 的新手,我有一个 Spring Boot 应用程序,我想设置一个在 Spring Boot 应用程序启动后仅执行一次的作业,因为我们每天都会运行应用程序 在我当前的解决方案中,我尝试...

回答 1 投票 0

尝试自动装配 jobLauncher 时出现错误“尚未设置 JobRepository”

我目前正在尝试通过将 jobLauncher 自动装配到控制器中来运行 Spring Batch 进程,这正是这里问题的提出者想要做的。但是,我收到错误提示...

回答 1 投票 0

在 Spring Boot Batch 中动态更改应用程序属性值

我创建了一个 Spring boot Batch 项目(2.3.0)。 我已经在 Linux 服务器(开发环境)中启动了相同的操作。 Batch/c 里面有一个 application.properties 和 application-dev.properties...

回答 1 投票 0

Spring Batch Partitioner:如何使具有 Spring Batch 功能的 Spring Boot 应用程序作为多节点工作

我们有一个 Spring Boot 应用程序,专门用于处理 Spring 批处理作业。在这里,我们使用 Spring Batch Parter 方法。选择这种方法是因为我们需要可恢复性/

回答 1 投票 0

嵌套对象上的Spring批处理块

我正在使用 Spring Batch 和 StaxEventItemReader 读取下面的 xml 文件 xml 文件示例: 我正在使用 Spring Batch 来读取下面的 xml 文件 StaxEventItemReader xml 文件示例: <ArrayOfStoreTransaction CustomerID="C1"> <PurchaseHistory Type="purchase.001" Count="2"> <StoreTransaction> <CustomerID>C1</CustomerID> <CustomerAccount>C1A</CustomerAccount> </StoreTransaction> <StoreTransaction> <CustomerID>C1</CustomerID> <CustomerAccount>C1A</CustomerAccount> </StoreTransaction> </PurchaseHistory> <PurchaseHistory Type="purchase.002" Count="1"> <StoreTransaction> <CustomerID>S3</CustomerID> <CustomerAccount>S3A</CustomerAccount> </StoreTransaction> </PurchaseHistory> <PurchaseHistory Type="purchase.003" Count="2"> <StoreTransaction> <CustomerID>S3</CustomerID> <CustomerAccount>S3A</CustomerAccount> </StoreTransaction> <StoreTransaction> <CustomerID>S3</CustomerID> <CustomerAccount>S3A</CustomerAccount> </StoreTransaction> </PurchaseHistory> </ArrayOfStoreTransaction> 这也是我用于绑定 xml 的对象 @XmlRootElement(name = "PurchaseHistory") @XmlAccessorType(XmlAccessType.FIELD) @Data public class PurchaseHistoryList { @XmlAttribute(name = "Type") private String type; @XmlAttribute(name = "Count") private int count; @XmlElement(name = "StoreTransaction") private List<StoreTransaction> storeTransactions; } @XmlAccessorType(XmlAccessType.FIELD) @Data class StoreTransaction { @XmlElement(name = "CustomerID") private String customerID; @XmlElement(name = "CustomerAccount") private String customerAccount; } 这是我的配置类: @Configuration @EnableBatchProcessing public class BatchConfiguration { @Bean public Step reportStep(StepBuilderFactory stepBuilderFactory, PlatformTransactionManager platformTransactionManager, ItemStreamReader<PurchaseHistoryList> reportItemReader, ItemWriter<PurchaseHistoryList> reportItemWriter, @Value("${chunk.size}") Integer chunkSize) { return stepBuilderFactory.get("reportStep") .transactionManager(platformTransactionManager) .<PurchaseHistoryList, PurchaseHistoryList>chunk(chunkSize) .reader(reportItemReader) .writer(reportItemWriter) .build(); } @Bean public Job reportJob(JobBuilderFactory jobBuilderFactory, JobRepository jobRepository, Step reportStep) { return jobBuilderFactory.get("reportJob") .repository(jobRepository) .start(reportStep) .build(); } @Bean public Unmarshaller paymentUnmarshaller() { Jaxb2Marshaller marshaller = new Jaxb2Marshaller(); marshaller.setClassesToBeBound(PurchaseHistoryList.class); return marshaller; } @Bean @StepScope public ItemStreamReader<PurchaseHistoryList> reportItemReader(@Value("#{jobParameters[filePath]}") String filePath) { StaxEventItemReader<PurchaseHistoryList> reader = new StaxEventItemReader<>(); reader.setResource(new FileSystemResource(filePath)); reader.setFragmentRootElementName("PurchaseHistory"); reader.setUnmarshaller(paymentUnmarshaller()); return reader; } @Bean public ItemWriter<PurchaseHistoryList> reportItemWriter(PurchaseHistoryListRepository repository) { return new PurchaseHistoryListWriter(repository); } } 我想要的是将块应用到 StoreTransaction 对象列表上。例如,如果块大小设置为 1,则提供给编写器的每个 PurchasingHistoryList 在每次迭代中应仅包含一个 StoreTransaction 对象。 那是不可能的。您将一项定义为 PurchaseHistory XML 元素,其中可能包含一个或多个 StoreTransaction 元素。 块大小应用于外部项目(而不是嵌套项目)。

回答 1 投票 0

Spring Batch 服务无限处理同一个文档

我有一个 Spring Batch 作业,它从一个 mongo 集合中读取并写入另一个集合,读者使用 mongoTemplate 的 findOne 查询来查找具有特定名称字段值的文档。来源

回答 1 投票 0

如何在 Spring Batch 中使用 MongoItemReader 进行聚合查询

需求发生了一些变化,我必须在 setQuery() 中使用聚合查询而不是基本查询。这可能吗? 请建议我该怎么做?我的聚合查询已准备就绪,但是...

回答 2 投票 0

Spring Batch 远程分块和远程分区的区别

Spring Batch 远程分块和远程分区有什么区别? 我无法理解 Spring Batch 中远程分块和远程分区之间的区别。可以吗...

回答 2 投票 0

Spring 批处理分区器:如何将 reader 类扩展为 bean 并在配置类中引用它

这是我的配置类, @豆 @StepScope 公共 JdbcPagingItemReader pagingItemReader( @Value("#{stepExecutionContext['fromRow']}")

回答 1 投票 0

Spring 批处理 - 创建一个文件,然后从同一个文件中读取

我应该从多个文件中读取,然后在应用一些处理和转换逻辑后写入单个文件。 为此,我创建了一个包含 3 个步骤的批处理作业,...

回答 1 投票 0

BeanCreationException:无法注入字段:不能有现有值

我在 Spring Batch 中为作业创建了一个测试类,效果很好。但是我必须添加一个扩展,它扩展了 SpringExtends,然后我收到一条错误消息,指出嵌套异常是 java.lang。

回答 1 投票 0

Spring boot 3.2.2升级相关警告-批量应用

我正在将 Java 从 8 升级到 21,将 Spring boot 从 2.2 升级到 3.2.2,以遵循 Spring Boot 和批处理迁移指南以及 Java 迁移指南。

回答 1 投票 0

无法调用“org.springframework.jdbc.core.JdbcTemplate.update(String, Object[])”,因为“this.jdbcTemplate”为空

我有一个Spring Batch项目,我需要在JobExecutionListener中集成一个jdbcTemplate。所以我配置了我的数据源和jdbcTemplate,如下所示: 导入java.util.Objects; 导入j...

回答 2 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.