歡迎您光臨本站 註冊首頁

Spring Batch 4.3.0-M1 釋出

←手機掃碼閱讀     admin @ 2020-06-28 , reply:0

Spring Batch 4.3.0 的第一個里程碑版本釋出了,可從里程碑倉庫獲取。

新特性

1. 新的同步 ItemStreamWriter

與 SynchronizedItemStreamReader 相似,此版本添加了 SynchronizedItemStreamWriter。此功能在多執行緒步驟中很有用,在這些步驟中,需要同步併發執行緒,以免覆蓋彼此的寫入。

2. 新增對 JpaPagingItemReader 中命名查詢的支援

JpaPagingItemReader 中可以使用命名查詢。但是,這需要建立一個自定義查詢提供程式,如下所示:


 JpaPagingItemReader<Foo> reader = new JpaPagingItemReaderBuilder<Foo>()
     .name("fooReader")
     .queryProvider(new AbstractJpaQueryProvider() {
        @Override
        public Query createQuery() {
           return getEntityManager().createNamedQuery("allFoos", Foo.class);
        }
 
        @Override
        public void afterPropertiesSet() throws Exception {
        }
     })
     // set other properties on the reader
     .build();

此版本引入了 JpaNamedQueryProvider 簡化配置,現在可以這樣寫:


 JpaPagingItemReader<Foo> reader = new JpaPagingItemReaderBuilder<Foo>()
 		.name("fooReader")
 		.queryProvider(new JpaNamedQueryProvider("allFoos", Foo.class))
 		// set other properties on the reader
 		.build();

3. 簡化 Spring Batch 測試的配置

與使用@ExtendWith(SpringExtension.class) 進行元註釋的 Spring Boot 測試註釋類似(例如 @SpringBootTest@WebMvcTest等),新版本將@SpringBatchTest 更新為使用 @ExtendWith(SpringExtension.class).進行元註釋。這簡化了使用 JUnit Jupiter 編寫測試時的配置。

此功能不影響 JUnit 4 使用者,僅涉及基於 JUnit 5 的測試。

此版本還帶來不少效能改進,詳情見更新說明:

https://spring.io/blog/2020/06/26/spring-batch-4-3-0-m1-is-released-now


[admin ]

來源:OsChina
連結:https://www.oschina.net/news/116757/spring-batch-4-3-0-m1-released
Spring Batch 4.3.0-M1 釋出已經有176次圍觀

http://coctec.com/news/all/show-post-240033.html