# Spring Batch 4.2 新特性

**URL:** <https://www.isharkfly.com/t/spring-batch-4-2/229>\
**Category:** 程序语言\
**Tags:** spring, java\
**Created:** [July 10, 2020, 5:09pm UTC](https://www.isharkfly.com/t/spring-batch-4-2/229 "2020-07-10T17:09:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![honeymoose](https://www.isharkfly.com/user_avatar/www.isharkfly.com/honeymoose/32/20796_2.png) [@honeymoose](https://www.isharkfly.com/u/honeymoose)\
**Post date:** [July 10, 2020, 5:09pm UTC](https://www.isharkfly.com/t/spring-batch-4-2/229/1 "2020-07-10T17:09:16Z")

</div>

Spring Batch 4.2 的发行版主要增强了下面的改进：

- 使用 [Micrometer](https://micrometer.io/) 来支持批量指标（batch metrics）
- 支持从 [Apache Kafka](https://kafka.apache.org/) topics 读取/写入（reading/writing） 数据
- 支持从 [Apache Avro](https://avro.apache.org/) 资源中读取/写入（reading/writing） 数据
- 改进支持文档

**使用 Micrometer 的批量指标** 本发行版本介绍了可以让你通过使用 Micrometer 来监控你的批量作业。在默认的情况下，Spring Batch 将会收集相关批量指标（包括，作业时间，步骤的时间，读取和写入的项目，以及其他的相关信息），和将这些指标通过 spring.batch 前缀（prefix）注册到 Micrometer 的全局指标中。  
这些指标可以发布到任何能够支持 Micrometer 的 [监控系统（monitoring system）](https://micrometer.io/docs/concepts#_supported_monitoring_systems)中。  
有关这个新特性的更多细节，请参考 [Monitoring and metrics](https://www.cwiki.us/display/SpringBatchZH/Monitoring+and+metrics) 章节中的内容。  
**Apache Kafka item 读取/写入** 本发行版本添加了一个新的 KafkaItemReader 和 KafkaItemWriter ，用来从 Kafka 的 topics 中读取和写入。  
有关更多这个新组建的信息，请参考：[Javadoc](https://docs.spring.io/spring-batch/4.2.x/api/index.html)。  
**Apache Avro item 读取/写入** 本发行版本添加了一个新的 AvroItemReader 和 AvroItemWriter，用来从 Avro 资源中读取和写入。  
有关更多这个新组建的信息，请参考： [Javadoc](https://docs.spring.io/spring-batch/4.2.x/api/index.html)。  
**文档更新** 对参考的文档进行更新，以便于与其他 Spring 项目的文档风格保持一致。  
**4.1 版本的文档更新** 下面的内容是 4.1 文档版本中的更新，我们没有将这部分内容从我们的 WIKI 中删除已保持历史信息的一致。  
请参考下面链接获得 4.1 文档版本中的更新，在官方的文档中，下面的内容已经不在 4.2 的文档中了。

- [@SpringBatchTest Annotation](https://www.cwiki.us/display/SpringBatchZH/@SpringBatchTest+Annotation)
- [@EnableBatchIntegration Annotation](https://www.cwiki.us/display/SpringBatchZH/@EnableBatchIntegration+Annotation)
- [JSON support](https://www.cwiki.us/display/SpringBatchZH/JSON+support)
- [Bean Validation API support](https://www.cwiki.us/display/SpringBatchZH/Bean+Validation+API+support)
- [JSR-305 Support](https://www.cwiki.us/display/SpringBatchZH/JSR-305+Support)
- [FlatFileItemWriterBuilder Enhancements](https://www.cwiki.us/display/SpringBatchZH/FlatFileItemWriterBuilder+Enhancements)

[https://www.cwiki.us/pages/viewpage.action?pageId=41685600](https://www.cwiki.us/pages/viewpage.action?pageId=41685600)
